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);
}