src/FlexApp/Extensions/RouterDecorator.php line 74

Open in your IDE?
  1. <?php
  2. namespace FlexApp\Extensions;
  3. use Symfony\Bundle\FrameworkBundle\Routing\Router;
  4. use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
  5. use Symfony\Component\Routing\RequestContext;
  6. use Symfony\Component\Routing\RouterInterface;
  7. use function Symfony\Component\String\u;
  8. class RouterDecorator implements WarmableInterfaceRouterInterface
  9. {
  10.     /** @var RouterInterface|Router */
  11.     protected $innerRouter;
  12.     public function __construct(Router $router)
  13.     {
  14.         $this->innerRouter $router;
  15.     }
  16.     /**
  17.      * @inheritDoc
  18.      */
  19.     public function setContext(RequestContext $context)
  20.     {
  21.         $this->innerRouter->setContext($context);
  22.     }
  23.     /**
  24.      * @inheritDoc
  25.      */
  26.     public function getContext()
  27.     {
  28.         return $this->innerRouter->getContext();
  29.     }
  30.     /**
  31.      * @inheritDoc
  32.      */
  33.     public function getRouteCollection()
  34.     {
  35.         return $this->innerRouter->getRouteCollection();
  36.     }
  37.     /**
  38.      * @inheritDoc
  39.      */
  40.     public function generate($name$parameters = [], $referenceType self::ABSOLUTE_PATH)
  41.     {
  42.         $url $this->innerRouter->generate($name$parameters$referenceType);
  43.         /*
  44.          * Для страниц интервью не меняем регистр заглавных букв, т.к. портальные unid чувствительны к регистру,
  45.          * и приведение к нижнему регистру влечет за собой баги на страницах интервью
  46.          */
  47.         if (u($url)->containsAny(['interview_link''s_interview'])) {
  48.             return $url;
  49.         }
  50.         if (preg_match('/(.*)\?(.*)/'$url$out)) {
  51.             $url trim(mb_convert_case($out[1], MB_CASE_LOWER'UTF-8'));
  52.             $url "{$url}?{$out[2]}";
  53.         } else {
  54.             $url trim(mb_convert_case($urlMB_CASE_LOWER'UTF-8'));
  55.         }
  56.         return $url;
  57.     }
  58.     /**
  59.      * @inheritDoc
  60.      */
  61.     public function match($pathinfo)
  62.     {
  63.         return $this->innerRouter->match($pathinfo);
  64.     }
  65.     public function warmUp($cacheDir)
  66.     {
  67.         $this->innerRouter->warmUp($cacheDir);
  68.     }
  69. }