Sulu\Component\Webspace\Manager\WebspaceManager::findUrlsByResourceLocator PHP Method

findUrlsByResourceLocator() public method

public findUrlsByResourceLocator ( $resourceLocator, $environment, $languageCode, $webspaceKey = null, $domain = null, $scheme = 'http' )
    public function findUrlsByResourceLocator($resourceLocator, $environment, $languageCode, $webspaceKey = null, $domain = null, $scheme = 'http')
    {
        $urls = [];
        $portals = $this->getWebspaceCollection()->getPortalInformations($environment, [RequestAnalyzerInterface::MATCH_TYPE_FULL]);
        foreach ($portals as $portalInformation) {
            $sameLocalization = $portalInformation->getLocalization()->getLocalization() === $languageCode;
            $sameWebspace = $webspaceKey === null || $portalInformation->getWebspace()->getKey() === $webspaceKey;
            $url = rtrim(sprintf('%s://%s%s', $scheme, $portalInformation->getUrl(), $resourceLocator), '/');
            if ($sameLocalization && $sameWebspace && $this->isFromDomain($url, $domain)) {
                $urls[] = $url;
            }
        }
        return $urls;
    }

Usage Example

示例#1
0
 public function testFindUrlsByResourceLocator()
 {
     $result = $this->webspaceManager->findUrlsByResourceLocator('/test', 'dev', 'en_us', 'massiveart');
     $this->assertEquals(['http://massiveart.lo/en-us/w/test', 'http://massiveart.lo/en-us/s/test'], $result);
     $result = $this->webspaceManager->findUrlsByResourceLocator('/test', 'dev', 'de_at', 'sulu_io');
     $this->assertEquals(['http://sulu.lo/test'], $result);
 }
All Usage Examples Of Sulu\Component\Webspace\Manager\WebspaceManager::findUrlsByResourceLocator