mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Optimized language routing
This commit is contained in:
parent
36f8e597f7
commit
edc8a941af
@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Controller\API;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractAPIController implements APIControllerInterface
|
||||
abstract class AbstractAPIController extends Controller implements APIControllerInterface
|
||||
{
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ use App\Controller\API\AbstractAPIController;
|
||||
class SourceApiController extends AbstractAPIController
|
||||
{
|
||||
/**
|
||||
* @Route("/api/{_locale}/source/{identifier}.{_format}",
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
@ -26,7 +26,7 @@ class SourceApiController extends AbstractAPIController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/{_locale}/source/.{_format}",
|
||||
* @Route("/{_locale}/api/source.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"POST"}
|
||||
* )
|
||||
@ -39,7 +39,7 @@ class SourceApiController extends AbstractAPIController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/{_locale}/source/{identifier}.{_format}",
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"PUT"}
|
||||
* )
|
||||
@ -52,7 +52,7 @@ class SourceApiController extends AbstractAPIController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/{_locale}/sources/.{_format}",
|
||||
* @Route("/{_locale}/api/sources/.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"GET"}
|
||||
* )
|
||||
@ -65,7 +65,7 @@ class SourceApiController extends AbstractAPIController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/api/{_locale}/source/{identifier}.{_format}",
|
||||
* @Route("/{_locale}/api/source/{identifier}.{_format}",
|
||||
* defaults={"_format"="json"} ,
|
||||
* methods={"DELETE"}
|
||||
* )
|
||||
|
@ -42,11 +42,17 @@ class ApiUrlReachableIntegrationTest extends KernelTestCase
|
||||
$this->language("$route/asdfg", $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement routing without i18l part!
|
||||
*
|
||||
* @param string $entity
|
||||
* @param string $method
|
||||
*/
|
||||
private function language(string $entity, string $method): void
|
||||
{
|
||||
$this->type('api/'.$entity, $method);
|
||||
foreach (LanguageType::getChoices() as $key => $value) {
|
||||
$this->type("api/$key/$entity", $method);
|
||||
//$this->type('api/'.$entity, $method);
|
||||
foreach (LanguageType::getChoices() as $language => $value) {
|
||||
$this->type("$language/api/$entity", $method);
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,10 +68,9 @@ class ApiUrlReachableIntegrationTest extends KernelTestCase
|
||||
{
|
||||
$request = new Request([], [], [], [], [], [
|
||||
'REQUEST_URI' => $url,
|
||||
'REQUEST_METHOD' => $method,
|
||||
]);
|
||||
$request->setMethod(Request::METHOD_GET);
|
||||
$request->setMethod($method);
|
||||
$response = static::$kernel->handle($request);
|
||||
$this->assertNotEquals(404, $response->getStatusCode(), "Route $url sends an 404 response!");
|
||||
$this->assertNotEquals(404, $response->getStatusCode(), "Route $url with Method $method sends an 404 response!");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user