comparison core/lib/Drupal/Core/Menu/LocalActionDefault.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
81 81
82 /** 82 /**
83 * {@inheritdoc} 83 * {@inheritdoc}
84 */ 84 */
85 public function getRouteParameters(RouteMatchInterface $route_match) { 85 public function getRouteParameters(RouteMatchInterface $route_match) {
86 $parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : []; 86 $route_parameters = isset($this->pluginDefinition['route_parameters']) ? $this->pluginDefinition['route_parameters'] : [];
87 $route = $this->routeProvider->getRouteByName($this->getRouteName()); 87 $route = $this->routeProvider->getRouteByName($this->getRouteName());
88 $variables = $route->compile()->getVariables(); 88 $variables = $route->compile()->getVariables();
89 89
90 // Normally the \Drupal\Core\ParamConverter\ParamConverterManager has 90 // Normally the \Drupal\Core\ParamConverter\ParamConverterManager has
91 // processed the Request attributes, and in that case the _raw_variables 91 // run, and the route parameters have been upcast. The original values can
92 // attribute holds the original path strings keyed to the corresponding 92 // be retrieved from the raw parameters. For example, if the route's path is
93 // slugs in the path patterns. For example, if the route's path pattern is
94 // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then 93 // /filter/tips/{filter_format} and the path is /filter/tips/plain_text then
95 // $raw_variables->get('filter_format') == 'plain_text'. 94 // $raw_parameters->get('filter_format') == 'plain_text'. Parameters that
96 $raw_variables = $route_match->getRawParameters(); 95 // are not represented in the route path as slugs might be added by a route
96 // enhancer and will not be present in the raw parameters.
97 $raw_parameters = $route_match->getRawParameters();
98 $parameters = $route_match->getParameters();
97 99
98 foreach ($variables as $name) { 100 foreach ($variables as $name) {
99 if (isset($parameters[$name])) { 101 if (isset($route_parameters[$name])) {
100 continue; 102 continue;
101 } 103 }
102 104
103 if ($raw_variables && $raw_variables->has($name)) { 105 if ($raw_parameters->has($name)) {
104 $parameters[$name] = $raw_variables->get($name); 106 $route_parameters[$name] = $raw_parameters->get($name);
105 } 107 }
106 elseif ($value = $route_match->getRawParameter($name)) { 108 elseif ($parameters->has($name)) {
107 $parameters[$name] = $value; 109 $route_parameters[$name] = $parameters->get($name);
108 } 110 }
109 } 111 }
112
110 // The UrlGenerator will throw an exception if expected parameters are 113 // The UrlGenerator will throw an exception if expected parameters are
111 // missing. This method should be overridden if that is possible. 114 // missing. This method should be overridden if that is possible.
112 return $parameters; 115 return $route_parameters;
113 } 116 }
114 117
115 /** 118 /**
116 * {@inheritdoc} 119 * {@inheritdoc}
117 */ 120 */