Reused middleware to check Accept-Language header on any HTTP related middleware

This commit is contained in:
Alejandro Celaya 2016-07-21 16:59:27 +02:00
parent fb9c7f8eec
commit cd5bbcd60a
5 changed files with 17 additions and 3 deletions

View File

@ -0,0 +1,14 @@
<?php
use Shlinkio\Shlink\Common\Middleware;
return [
'middleware_pipeline' => [
'pre-routing' => [
'middleware' => [
Middleware\LocaleMiddleware::class,
],
'priority' => 5,
],
],
];

View File

@ -5,6 +5,7 @@ use Doctrine\ORM\EntityManager;
use Shlinkio\Shlink\Common\Factory\CacheFactory;
use Shlinkio\Shlink\Common\Factory\EntityManagerFactory;
use Shlinkio\Shlink\Common\Factory\TranslatorFactory;
use Shlinkio\Shlink\Common\Middleware\LocaleMiddleware;
use Shlinkio\Shlink\Common\Service\IpLocationResolver;
use Shlinkio\Shlink\Common\Twig\Extension\TranslatorExtension;
use Zend\I18n\Translator\Translator;
@ -20,6 +21,7 @@ return [
IpLocationResolver::class => AnnotatedFactory::class,
Translator::class => TranslatorFactory::class,
TranslatorExtension::class => AnnotatedFactory::class,
LocaleMiddleware::class => AnnotatedFactory::class,
],
'aliases' => [
'em' => EntityManager::class,

View File

@ -1,5 +1,5 @@
<?php
namespace Shlinkio\Shlink\Rest\Middleware;
namespace Shlinkio\Shlink\Common\Middleware;
use Acelaya\ZsmAnnotatedServices\Annotation\Inject;
use Psr\Http\Message\ResponseInterface as Response;

View File

@ -8,7 +8,6 @@ return [
'path' => '/rest',
'middleware' => [
Middleware\CheckAuthenticationMiddleware::class,
Middleware\LocaleMiddleware::class,
Middleware\CrossDomainMiddleware::class,
],
'priority' => 5,

View File

@ -19,7 +19,6 @@ return [
Middleware\CrossDomainMiddleware::class => InvokableFactory::class,
Middleware\CheckAuthenticationMiddleware::class => AnnotatedFactory::class,
Middleware\LocaleMiddleware::class => AnnotatedFactory::class,
],
],