comparison core/lib/Drupal/Core/Controller/TitleResolver.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
3 namespace Drupal\Core\Controller; 3 namespace Drupal\Core\Controller;
4 4
5 use Drupal\Core\StringTranslation\StringTranslationTrait; 5 use Drupal\Core\StringTranslation\StringTranslationTrait;
6 use Drupal\Core\StringTranslation\TranslationInterface; 6 use Drupal\Core\StringTranslation\TranslationInterface;
7 use Symfony\Component\HttpFoundation\Request; 7 use Symfony\Component\HttpFoundation\Request;
8 use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
8 use Symfony\Component\Routing\Route; 9 use Symfony\Component\Routing\Route;
9 10
10 /** 11 /**
11 * Provides the default implementation of the title resolver interface. 12 * Provides the default implementation of the title resolver interface.
12 */ 13 */
19 * @var \Drupal\Core\Controller\ControllerResolverInterface 20 * @var \Drupal\Core\Controller\ControllerResolverInterface
20 */ 21 */
21 protected $controllerResolver; 22 protected $controllerResolver;
22 23
23 /** 24 /**
25 * The argument resolver.
26 *
27 * @var \Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface
28 */
29 protected $argumentResolver;
30
31 /**
24 * Constructs a TitleResolver instance. 32 * Constructs a TitleResolver instance.
25 * 33 *
26 * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver 34 * @param \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver
27 * The controller resolver. 35 * The controller resolver.
28 * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation 36 * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
29 * The translation manager. 37 * The translation manager.
38 * @param \Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface $argument_resolver
39 * The argument resolver.
30 */ 40 */
31 public function __construct(ControllerResolverInterface $controller_resolver, TranslationInterface $string_translation) { 41 public function __construct(ControllerResolverInterface $controller_resolver, TranslationInterface $string_translation, ArgumentResolverInterface $argument_resolver) {
32 $this->controllerResolver = $controller_resolver; 42 $this->controllerResolver = $controller_resolver;
33 $this->stringTranslation = $string_translation; 43 $this->stringTranslation = $string_translation;
44 $this->argumentResolver = $argument_resolver;
34 } 45 }
35 46
36 /** 47 /**
37 * {@inheritdoc} 48 * {@inheritdoc}
38 */ 49 */
41 // A dynamic title takes priority. Route::getDefault() returns NULL if the 52 // A dynamic title takes priority. Route::getDefault() returns NULL if the
42 // named default is not set. By testing the value directly, we also avoid 53 // named default is not set. By testing the value directly, we also avoid
43 // trying to use empty values. 54 // trying to use empty values.
44 if ($callback = $route->getDefault('_title_callback')) { 55 if ($callback = $route->getDefault('_title_callback')) {
45 $callable = $this->controllerResolver->getControllerFromDefinition($callback); 56 $callable = $this->controllerResolver->getControllerFromDefinition($callback);
46 $arguments = $this->controllerResolver->getArguments($request, $callable); 57 $arguments = $this->argumentResolver->getArguments($request, $callable);
47 $route_title = call_user_func_array($callable, $arguments); 58 $route_title = call_user_func_array($callable, $arguments);
48 } 59 }
49 elseif ($title = $route->getDefault('_title')) { 60 elseif ($title = $route->getDefault('_title')) {
50 $options = []; 61 $options = [];
51 if ($context = $route->getDefault('_title_context')) { 62 if ($context = $route->getDefault('_title_context')) {