mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-18 19:09:20 +02:00
Optimized SourceApiController
This commit is contained in:
parent
93606503f6
commit
d99c05908b
@ -45,11 +45,4 @@ abstract class AbstractAPIController extends AbstractController
|
|||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
abstract public function delete(Request $request, $identifier): Response;
|
abstract public function delete(Request $request, $identifier): Response;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Request $request HTTP Method GET with filtering parameters
|
|
||||||
*
|
|
||||||
* @return Response
|
|
||||||
*/
|
|
||||||
abstract public function list(Request $request): Response;
|
|
||||||
}
|
}
|
||||||
|
@ -14,34 +14,48 @@ use Infinito\DBAL\Types\Meta\Right\LayerType;
|
|||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*
|
*
|
||||||
* @todo Implement!
|
* @see https://symfony.com/blog/new-in-symfony-4-1-prefix-imported-route-names
|
||||||
|
* @see https://symfony.com/blog/new-in-symfony-4-1-internationalized-routing
|
||||||
|
* @Route(
|
||||||
|
* {
|
||||||
|
* "en":"/source/{identity}.{_format}",
|
||||||
|
* "de":"/quelle/{identity}.{_format}",
|
||||||
|
* "eo":"/fonto/{identity}.{_format}",
|
||||||
|
* "es":"/fontanar/{identity}.{_format}",
|
||||||
|
* "nl":"/bron/{identity}.{_format}"
|
||||||
|
* },
|
||||||
|
* defaults={
|
||||||
|
* "identity"="",
|
||||||
|
* "_format"="json"
|
||||||
|
* } ,
|
||||||
|
* name="source_"
|
||||||
|
* )
|
||||||
*/
|
*/
|
||||||
class SourceApiController extends AbstractAPIController
|
class SourceApiController extends AbstractAPIController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
* @Route(
|
||||||
* defaults={"_format"="json"} ,
|
|
||||||
* methods={"GET"}
|
* methods={"GET"}
|
||||||
* )
|
* )
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see \Infinito\Controller\API\AbstractAPIController::read()
|
* @see \Infinito\Controller\API\AbstractAPIController::read()
|
||||||
*/
|
*/
|
||||||
public function read(MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService, $identifier): Response
|
public function read(MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService, $identity): Response
|
||||||
{
|
{
|
||||||
$requestedActionService->setActionType(ActionType::READ);
|
$requestedActionService->setActionType(ActionType::READ);
|
||||||
$requestedActionService->setLayer(LayerType::SOURCE);
|
$requestedActionService->setLayer(LayerType::SOURCE);
|
||||||
$requestedActionService->getRequestedEntity()->setIdentity($identifier);
|
$requestedActionService->getRequestedEntity()->setIdentity($identity);
|
||||||
$view = $mvcRoutineService->process();
|
$view = $mvcRoutineService->process();
|
||||||
|
|
||||||
return $this->handleView($view);
|
return $this->handleView($view);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
*@Route(
|
||||||
* defaults={"_format"="json"} ,
|
|
||||||
* methods={"PUT"}
|
* methods={"PUT"}
|
||||||
* )
|
* )
|
||||||
|
*
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see \Infinito\Controller\API\AbstractAPIController::update()
|
* @see \Infinito\Controller\API\AbstractAPIController::update()
|
||||||
@ -51,21 +65,7 @@ class SourceApiController extends AbstractAPIController
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{_locale}/api/sources/.{_format}",
|
* @Route(
|
||||||
* defaults={"_format"="json"} ,
|
|
||||||
* methods={"GET"}
|
|
||||||
* )
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @see \Infinito\Controller\API\AbstractAPIController::list()
|
|
||||||
*/
|
|
||||||
public function list(Request $request): Response
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
|
||||||
* defaults={"_format"="json"} ,
|
|
||||||
* methods={"DELETE"}
|
* methods={"DELETE"}
|
||||||
* )
|
* )
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace tests\Integration\Domain\FixtureManagement;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class ImprintFixtureSourceTest extends KernelTestCase
|
||||||
|
{
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testImprintSourceReachable(): void
|
||||||
|
{
|
||||||
|
$request = new Request([], [], [], [], [], [
|
||||||
|
'REQUEST_URI' => 'source/imprint.html',
|
||||||
|
]);
|
||||||
|
$request->setMethod(Request::METHOD_GET);
|
||||||
|
$response = static::$kernel->handle($request);
|
||||||
|
$this->assertEquals(200, $response->getStatusCode());
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user