/** * @param ContentInterface $content * @param array $args * * @return string */ public function toHTML(ContentInterface $content, array $args) { if (isset($args['output'])) { return $args['output']; } $tags = array_merge($args, $content->getMetaTagArray()); if (!isset($tags['pre'])) { $pre = "\n "; } else { $pre = $tags['pre']; unset($tags['pre']); } return self::createMetaTags($pre, $tags, $this->filter); }
/** * @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'])); }
protected function metaTagToHtml(ContentInterface $content, $arguments) { $serviceId = $content->getHtmlRenderServiceId(); $renderer = $this->container->get($serviceId); if (!$renderer instanceof HtmlRendererInterface) { throw new \Exception("RenderService({$serviceId}) must implements HtmlRendererInterface"); } $renderer->setFilter($this); return $renderer->toHTML($content, $arguments); }