/** * Get the URL to a path or locator resource. * * @param string $path * @param mixed $parameters * @param mixed $referenceType * @return string */ public function to($path = '', $parameters = [], $referenceType = UrlGenerator::ABSOLUTE_PATH) { if (0 === strpos($path, '@')) { return $this->route($path, $parameters, $referenceType); } try { if (filter_var($path, FILTER_VALIDATE_URL) !== false) { $path = $this->locator->findResource($path); } } catch (InvalidArgumentException $e) { return $path; } if ($this->isAbsolutePath($path)) { $path = str_replace('\\', '/', $path); $path = strpos($path, $base = $this->context->getScriptPath()) === 0 ? substr($path, strlen($base)) : $path; } if ($query = http_build_query($parameters, '', '&')) { $query = '?' . $query; } if ($referenceType !== UrlGenerator::BASE_PATH) { $path = $this->base($referenceType) . '/' . trim($path, '/'); } return $path . $query; }
/** * {@inheritdoc} */ protected function getConfig($filename, $parameters) { return parent::getConfig($this->locator->findResource($filename), $parameters); }
/** * {@inheritdoc} */ protected function getTarget($uri) { return self::$locator->findResource($uri); }