/** * @param ContentInterface $content * @param bool $originUrl * * @return string */ public function getUrl(ContentInterface $content, $originUrl = true) { if (!($info = $content->getPathInfo())) { return; } $router = $this->getRouter(); try { $parameters = $info['__defaults']; foreach ($info as $key => $value) { if (strpos($key, '_') === 0) { continue; } $parameters[$key] = $value; } if ($originUrl) { $parameters[UrlGenerator::GENERATE_NORMAL_ROUTE] = true; } return $router->generate($info['_route'], $parameters); } catch (\Exception $e) { return $e->getMessage(); } }
public function updatePathInfo(ContentInterface $content) { if (!$content->isChangedPathInfo()) { return; } $info = $this->getPathInfoFromMetaTagKey($content->getKeyword()); $arr = $this->keyGenerator->splitLocaledKeyword($content->getKeyword()); $contentInfo = $content->getPathInfo(); $contentInfo['_locale'] = $arr[0]; // add locale routing info after controller foreach ($info as $key => $value) { $contentInfo[$key] = $value; } $contentInfo = array_merge($contentInfo, $this->getQueryInfo($content->getKeyword())); $content->setChangedPathInfo($contentInfo); $content->setRouteDefaults($this->getDefaults($contentInfo['_route'])); }