* command and user actions added

* language model added
This commit is contained in:
Danyi Dávid
2016-08-15 21:45:46 +02:00
parent 15fe800840
commit 773769d7d6
25 changed files with 784 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace App\Action\User;
use App\Action\AbstractFormAction;
use App\Service\EntityServiceInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\JsonResponse;
class PostAction extends AbstractFormAction
{
/**
* @var EntityServiceInterface
*/
private $entityService;
public function __construct(EntityServiceInterface $entityService)
{
$this->entityService = $entityService;
}
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
{
$data = $this->getRequestData($request);
$result = $this->entityService->create($data);
if (false === $result) {
$result = new JsonResponse(false);
return $result->withStatus(500, 'Failed to insert record.');
}
return new JsonResponse($result);
}
}