protected function getValue(MenuItemParameter $parameter) { if ($parameter->getUseValueFromContext()) { $routeParameter = $parameter->getParameter(); // If the current context has this parameter, use it if ($this->router->getContext()->hasParameter($routeParameter->getParameter())) { return $this->router->getContext()->getParameter($routeParameter->getParameter()); } // Otherwise, use the default value for this route // Note: This might change, and upon importing routes anew // The URLs generated will now use the new default value $default = $routeParameter->getDefaultValue(); if ($default) { return $default; } } // If no value was found in the context or the default route parameter value // return the last copy of its default return $parameter->getValue(); }