eZ\Publish\Core\Repository\URLAliasService::createUrlAlias PHP Method

createUrlAlias() public method

This method runs URL filters 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 createUrlAlias ( eZ\Publish\API\Repository\Values\Content\Location $location, string $path, string $languageCode, boolean $forwarding = false, boolean $alwaysAvailable = false ) : eZ\Publish\API\Repository\Values\Content\URLAlias
$location eZ\Publish\API\Repository\Values\Content\Location
$path string
$languageCode string the languageCode for which this alias is valid
$forwarding boolean if true a redirect is performed
$alwaysAvailable boolean
return eZ\Publish\API\Repository\Values\Content\URLAlias
    public function createUrlAlias(Location $location, $path, $languageCode, $forwarding = false, $alwaysAvailable = false)
    {
        $path = $this->cleanUrl($path);
        $this->repository->beginTransaction();
        try {
            $spiUrlAlias = $this->urlAliasHandler->createCustomUrlAlias($location->id, $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);
    }