‪TYPO3CMS  9.5
UrlGenerator.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Symfony\Component\Routing\Generator\UrlGenerator as SymfonyUrlGenerator;
21 
25 class ‪UrlGenerator extends SymfonyUrlGenerator
26 {
30  protected ‪$mappableProcessor;
31 
33  {
34  $this->mappableProcessor = ‪$mappableProcessor;
35  }
36 
42  protected function ‪doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes = [])
43  {
45  $route = $this->routes->get($name);
46  // _appliedDefaults contains internal(!) values (mapped default values are not generated yet)
47  // (keys used are deflated and need to be inflated later using VariableProcessor)
48  $relevantDefaults = array_intersect_key($defaults, array_flip($route->compile()->getPathVariables()));
49  $route->setOption('_appliedDefaults', array_diff_key($relevantDefaults, $parameters));
50  // map default values for URL generation (e.g. '1' becomes 'one' if defined in aspect)
51  ‪$mappableProcessor = $this->mappableProcessor ?? new ‪MappableProcessor();
52  ‪$mappableProcessor->‪generate($route, $defaults);
53 
54  return parent::doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, $requiredSchemes);
55  }
56 }
‪TYPO3\CMS\Core\Routing\UrlGenerator\doGenerate
‪doGenerate($variables, $defaults, $requirements, $tokens, $parameters, $name, $referenceType, $hostTokens, array $requiredSchemes=[])
Definition: UrlGenerator.php:41
‪TYPO3\CMS\Core\Routing\Aspect\MappableProcessor\generate
‪bool generate(Route $route, array &$attributes)
Definition: MappableProcessor.php:58
‪TYPO3\CMS\Core\Routing
‪TYPO3\CMS\Core\Routing\UrlGenerator\injectMappableProcessor
‪injectMappableProcessor(MappableProcessor $mappableProcessor)
Definition: UrlGenerator.php:31
‪TYPO3\CMS\Core\Routing\UrlGenerator
Definition: UrlGenerator.php:26
‪TYPO3\CMS\Core\Routing\Aspect\MappableProcessor
Definition: MappableProcessor.php:25
‪TYPO3\CMS\Core\Routing\UrlGenerator\$mappableProcessor
‪MappableProcessor $mappableProcessor
Definition: UrlGenerator.php:29