eZ\Publish\Core\Repository\URLAliasService::createGlobalUrlAlias PHP Метод

createGlobalUrlAlias() публичный Метод

This method does not handle location resources - if a user enters a location target the createCustomUrlAlias method has to be used. This method runs URL filters and and transformers before storing them. Hence the path returned in the URLAlias Value may differ from the given. $alwaysAvailable makes the alias available in all languages.
public createGlobalUrlAlias ( string $resource, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$resource string
$path string
$languageCode string
$forwarding boolean
$alwaysAvailable boolean
Результат eZ\Publish\API\Repository\Values\Content\URLAlias
    public function createGlobalUrlAlias($resource, $path, $languageCode, $forwarding = false, $alwaysAvailable = false)
    {
        if (!preg_match('#^([a-zA-Z0-9_]+):(.+)$#', $resource, $matches)) {
            throw new InvalidArgumentException('$resource', 'argument is not valid');
        }
        $path = $this->cleanUrl($path);
        if ($matches[1] === 'eznode' || 0 === strpos($resource, 'module:content/view/full/')) {
            if ($matches[1] === 'eznode') {
                $locationId = $matches[2];
            } else {
                $resourcePath = explode('/', $matches[2]);
                $locationId = end($resourcePath);
            }
            return $this->createUrlAlias($this->repository->getLocationService()->loadLocation($locationId), $path, $languageCode, $forwarding, $alwaysAvailable);
        }
        $this->repository->beginTransaction();
        try {
            $spiUrlAlias = $this->urlAliasHandler->createGlobalUrlAlias($matches[1] . ':' . $this->cleanUrl($matches[2]), $path, $forwarding, $languageCode, $alwaysAvailable);
            $this->repository->commit();
        } catch (ForbiddenException $e) {
            $this->repository->rollback();
            throw new InvalidArgumentException('$path', $e->getMessage(), $e);
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
        return $this->buildUrlAliasDomainObject($spiUrlAlias, $path);
    }