findUrlByResourceLocator() public method

Returns the main url for resourcelocator.
public findUrlByResourceLocator ( string $resourceLocator, string $environment, string $languageCode, null | string $webspaceKey = null, null | string $domain = null, string $scheme = 'http' ) : string
$resourceLocator string
$environment string
$languageCode string
$webspaceKey null | string
$domain null | string
$scheme string
return string
示例#1
0
文件: SeoEnhancer.php 项目: sulu/sulu
 /**
  * {@inheritdoc}
  */
 protected function doEnhance(CustomUrlBehavior $customUrl, Webspace $webspace, array $defaults, Request $request)
 {
     $seo = ['noFollow' => $customUrl->isNoFollow(), 'noIndex' => $customUrl->isNoIndex()];
     if ($customUrl->isCanonical()) {
         $resourceSegment = $customUrl->getTargetDocument()->getResourceSegment();
         $seo['canonicalUrl'] = $this->webspaceManager->findUrlByResourceLocator($resourceSegment, $defaults['_environment'], $customUrl->getTargetLocale(), $webspace->getKey());
     }
     return ['_seo' => $seo];
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 protected function doEnhance(CustomUrlBehavior $customUrl, Webspace $webspace, array $defaults, Request $request)
 {
     $resourceSegment = '/';
     if ($customUrl->getTargetDocument() !== null) {
         $resourceSegment = $customUrl->getTargetDocument()->getResourceSegment();
     }
     $url = $this->webspaceManager->findUrlByResourceLocator($resourceSegment, $defaults['_environment'], $customUrl->getTargetLocale(), $defaults['_webspace']->getKey());
     return ['_controller' => 'SuluWebsiteBundle:Default:redirect', 'url' => $url];
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function sitemapUrlFunction($url, $locale = null, $webspaceKey = null)
 {
     if ($webspaceKey === null) {
         $webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
     }
     if ($locale === null) {
         $locale = $this->requestAnalyzer->getCurrentLocalization()->getLocalization();
     }
     return $this->webspaceManager->findUrlByResourceLocator($url, $this->environment, $locale, $webspaceKey);
 }
示例#4
0
 /**
  * {@inheritdoc}
  */
 public function getContentPath($route, $webspaceKey = null, $locale = null, $domain = null, $scheme = null, $withoutDomain = true)
 {
     // if the request analyzer null or a route is passed which is relative or inclusive a domain nothing should be
     // done (this is important for external-links in navigations)
     if (!$this->requestAnalyzer || strpos($route, '/') !== 0) {
         return $route;
     }
     $scheme = $scheme ?: $this->requestAnalyzer->getAttribute('scheme');
     $locale = $locale ?: $this->requestAnalyzer->getCurrentLocalization()->getLocale();
     $webspaceKey = $webspaceKey ?: $this->requestAnalyzer->getWebspace()->getKey();
     $url = null;
     $host = $this->requestAnalyzer->getAttribute('host');
     if (!$domain && $this->webspaceManager->findWebspaceByKey($webspaceKey)->hasDomain($host, $this->environment)) {
         $domain = $host;
     }
     $url = $this->webspaceManager->findUrlByResourceLocator($route, $this->environment, $locale, $webspaceKey, $domain, $scheme);
     if (!$withoutDomain && !$url) {
         $url = $this->webspaceManager->findUrlByResourceLocator($route, $this->environment, $locale, $webspaceKey, null, $scheme);
     }
     return $url ?: $route;
 }
示例#5
0
 /**
  * Returns new link item.
  *
  * @param Content $content
  * @param string $locale
  * @param string $scheme
  *
  * @return LinkItem
  */
 protected function getLinkItem(Content $content, $locale, $scheme)
 {
     $published = !empty($content->getPropertyWithDefault('published'));
     $url = $this->webspaceManager->findUrlByResourceLocator($content->getUrl(), $this->environment, $locale, $content->getWebspaceKey(), null, $scheme);
     return new LinkItem($content->getId(), $content->getPropertyWithDefault('title'), $url, $published);
 }