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