comparison core/lib/Drupal/Core/Menu/LocalTaskDefault.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
39 39
40 /** 40 /**
41 * {@inheritdoc} 41 * {@inheritdoc}
42 */ 42 */
43 public function getRouteParameters(RouteMatchInterface $route_match) { 43 public function getRouteParameters(RouteMatchInterface $route_match) {
44 $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; 44 $route_parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
45 $route = $this->routeProvider()->getRouteByName($this->getRouteName()); 45 $route = $this->routeProvider()->getRouteByName($this->getRouteName());
46 $variables = $route->compile()->getVariables(); 46 $variables = $route->compile()->getVariables();
47 47
48 // Normally the \Drupal\Core\ParamConverter\ParamConverterManager has 48 // Normally the \Drupal\Core\ParamConverter\ParamConverterManager has
49 // processed the Request attributes, and in that case the _raw_variables 49 // run, and the route parameters have been upcast. The original values can
50 // attribute holds the original path strings keyed to the corresponding 50 // be retrieved from the raw parameters. For example, if the route's path is
51 // slugs in the path patterns. For example, if the route's path pattern is
52 // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then 51 // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
53 // $raw_variables->get('filter_format') == 'plain_text'. 52 // $raw_parameters->get('filter_format') == 'plain_text'. Parameters that
54 53 // are not represented in the route path as slugs might be added by a route
55 $raw_variables = $route_match->getRawParameters(); 54 // enhancer and will not be present in the raw parameters.
55 $raw_parameters = $route_match->getRawParameters();
56 $parameters = $route_match->getParameters();
56 57
57 foreach ($variables as $name) { 58 foreach ($variables as $name) {
58 if (isset($parameters[$name])) { 59 if (isset($route_parameters[$name])) {
59 continue; 60 continue;
60 } 61 }
61 62
62 if ($raw_variables && $raw_variables->has($name)) { 63 if ($raw_parameters->has($name)) {
63 $parameters[$name] = $raw_variables->get($name); 64 $route_parameters[$name] = $raw_parameters->get($name);
64 } 65 }
65 elseif ($value = $route_match->getRawParameter($name)) { 66 elseif ($parameters->has($name)) {
66 $parameters[$name] = $value; 67 $route_parameters[$name] = $parameters->get($name);
67 } 68 }
68 } 69 }
70
69 // The UrlGenerator will throw an exception if expected parameters are 71 // The UrlGenerator will throw an exception if expected parameters are
70 // missing. This method should be overridden if that is possible. 72 // missing. This method should be overridden if that is possible.
71 return $parameters; 73 return $route_parameters;
72 } 74 }
73 75
74 /** 76 /**
75 * {@inheritdoc} 77 * {@inheritdoc}
76 */ 78 */