Chris@0: controllerResolver = $controller_resolver; Chris@0: $this->stringTranslation = $string_translation; Chris@17: $this->argumentResolver = $argument_resolver; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getTitle(Request $request, Route $route) { Chris@0: $route_title = NULL; Chris@0: // A dynamic title takes priority. Route::getDefault() returns NULL if the Chris@0: // named default is not set. By testing the value directly, we also avoid Chris@0: // trying to use empty values. Chris@0: if ($callback = $route->getDefault('_title_callback')) { Chris@0: $callable = $this->controllerResolver->getControllerFromDefinition($callback); Chris@17: $arguments = $this->argumentResolver->getArguments($request, $callable); Chris@0: $route_title = call_user_func_array($callable, $arguments); Chris@0: } Chris@0: elseif ($title = $route->getDefault('_title')) { Chris@0: $options = []; Chris@0: if ($context = $route->getDefault('_title_context')) { Chris@0: $options['context'] = $context; Chris@0: } Chris@0: $args = []; Chris@0: if (($raw_parameters = $request->attributes->get('_raw_variables'))) { Chris@0: foreach ($raw_parameters->all() as $key => $value) { Chris@0: $args['@' . $key] = $value; Chris@0: $args['%' . $key] = $value; Chris@0: } Chris@0: } Chris@0: if ($title_arguments = $route->getDefault('_title_arguments')) { Chris@0: $args = array_merge($args, (array) $title_arguments); Chris@0: } Chris@0: Chris@0: // Fall back to a static string from the route. Chris@0: $route_title = $this->t($title, $args, $options); Chris@0: } Chris@0: return $route_title; Chris@0: } Chris@0: Chris@0: }