/** * @return array */ public function getDefaults() : array { if (!isset($this->cache[__FUNCTION__])) { /** @var RouteCollection $collection */ $collection = $this->collection; $this->cache[__FUNCTION__] = parent::getDefaults() + $collection->getDefaults(); } return $this->cache[__FUNCTION__]; }
/** * @param BaseContext|Context $context * @param BaseRoute|Route $route * @return array */ public function extract(BaseContext $context, BaseRoute $route) : array { /** @var Context $context */ /** @var Route $route */ $names = []; if (null !== ($domain = $route->get('domain'))) { $names += $this->getRouteCollection()->getDomainCompiler()->getNames($domain); } $names += $this->getCompiler()->getNames($route->getPattern()); $regex = $this->getRouteCollection()->getRegex($route->getID()); $values = $this->getCompiler()->getValues($regex, (string) $context); return array_intersect_key($values, array_flip($names)) + $route->getDefaults(); }