4. Status # Title Status # Title
X 0 Autoloading Standard B 10 Security Reporting Process
A 1 Basic Coding Standard A 11 Container Interface
A 2 Coding Style Guide R 12 Extended Coding Style Guide
A 3 Logger Interface A 13 Hypermedia Links
A 4 Autoloading Standard B 14 Event Manager
B 5 PHPDoc Standard A 15 HTTP Handlers
A 6 Caching Interface A 16 Simple Cache
A 7 HTTP Message Interface D 17 HTTP Factories
B 8 Huggable Interface D 18 HTTP Client
B 9 Security Advisories
5. Status # Title Status # Title
X 0 Autoloading Standard B 10 Security Reporting Process
A 1 Basic Coding Standard A 11 Container Interface
A 2 Coding Style Guide R 12 Extended Coding Style Guide
A 3 Logger Interface A 13 Hypermedia Links
A 4 Autoloading Standard B 14 Event Manager
B 5 PHPDoc Standard A 15 HTTP Handlers
A 6 Caching Interface A 16 Simple Cache
A 7 HTTP Message Interface D 17 HTTP Factories
B 8 Huggable Interface D 18 HTTP Client
B 9 Security Advisories
18. <?php
namespace AppController;
use ApplicationCommandCreaElementoCommand;
use PsrHttpMessageServerRequestInterface;
use SimpleBusMessageBusMessageBus;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyBundleFrameworkBundleControllerAbstractController
final class PippoController extends AbstractController
{
public function creaElemento(MessageBus $bus, Request $request): Response
{
$command = CreaElementoCommand::fromRequest($request);
$bus->handle($command);
return $this->json([], Response::HTTP_CREATED);
}
}
19. <?php
namespace ApplicationCommand;
use SymfonyComponentHttpFoundationRequest;
class CreaElementoCommand
{
public $nome;
public $email;
public $telefono;
/* ... */
public static function fromRequest(Request $request): self
{
$params = $request->request->all();
$command = new static();
foreach ($params as $name => $value) {
if (property_exists(self::class, $name) {
$command->$name = $value;
}
}
return $command;
}
}
20. <?php
namespace ApplicationCommand;
use PsrHttpMessageServerRequestInterface;
class CreaElementoCommand
{
public $nome;
public $email;
public $telefono;
/* ... */
public static function fromRequest(ServerRequestInterface $request): self
{
$params = $request->getParsedBody();
$command = new static();
foreach ($params as $name => $value) {
if (property_exists(self::class, $name) {
$command->$name = $value;
}
}
return $command;
}
}
22. <?php
namespace AppController;
use ApplicationCommandCreaElementoCommand;
use SimpleBusMessageBusMessageBus;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyBundleFrameworkBundleControllerAbstractController
final class PippoController extends AbstractController
{
public function creaElemento(MessageBus $bus, Request $request): Response
{
$command = CreaElementoCommand::fromRequest($request);
$bus->handle($command);
return $this->json([], Response::HTTP_CREATED);
}
}
23. <?php
namespace AppController;
use ApplicationCommandCreaElementoCommand;
use PsrHttpMessageServerRequestInterface;
use SimpleBusMessageBusMessageBus;
use SymfonyComponentHttpFoundationResponse;
use SymfonyBundleFrameworkBundleControllerAbstractController
final class PippoController extends AbstractController
{
public function creaElemento(MessageBus $bus, ServerRequestInterface $request): Response
{
$command = CreaElementoCommand::fromRequest($request);
$bus->handle($command);
return $this->json([], Response::HTTP_CREATED);
}
}