* command and user actions added
* language model added
This commit is contained in:
35
src/App/Action/Comment/GetAction.php
Normal file
35
src/App/Action/Comment/GetAction.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Action\Comment;
|
||||
|
||||
use App\Service\EntityServiceInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Zend\Diactoros\Response\JsonResponse;
|
||||
|
||||
class GetAction
|
||||
{
|
||||
|
||||
/**
|
||||
* @var EntityServiceInterface
|
||||
*/
|
||||
private $entityService;
|
||||
|
||||
public function __construct(EntityServiceInterface $entityService)
|
||||
{
|
||||
$this->entityService = $entityService;
|
||||
}
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
|
||||
{
|
||||
$id = $request->getAttribute('id');
|
||||
$entity = $this->entityService->get($id);
|
||||
|
||||
if (null === $entity) {
|
||||
$ret = new JsonResponse(false);
|
||||
return $ret->withStatus(404);
|
||||
}
|
||||
|
||||
return new JsonResponse($entity);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user