eZ\Publish\Core\REST\Server\Controller\URLAlias::createURLAlias PHP Method

createURLAlias() public method

Creates a new URL alias.
public createURLAlias ( Request $request ) : CreatedURLAlias
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\CreatedURLAlias
    public function createURLAlias(Request $request)
    {
        $urlAliasCreate = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
        if ($urlAliasCreate['_type'] === 'LOCATION') {
            $locationPathParts = explode('/', $this->requestParser->parseHref($urlAliasCreate['location']['_href'], 'locationPath'));
            $location = $this->locationService->loadLocation(array_pop($locationPathParts));
            try {
                $createdURLAlias = $this->urlAliasService->createUrlAlias($location, $urlAliasCreate['path'], $urlAliasCreate['languageCode'], $urlAliasCreate['forward'], $urlAliasCreate['alwaysAvailable']);
            } catch (InvalidArgumentException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        } else {
            try {
                $createdURLAlias = $this->urlAliasService->createGlobalUrlAlias($urlAliasCreate['resource'], $urlAliasCreate['path'], $urlAliasCreate['languageCode'], $urlAliasCreate['forward'], $urlAliasCreate['alwaysAvailable']);
            } catch (InvalidArgumentException $e) {
                throw new ForbiddenException($e->getMessage());
            }
        }
        return new Values\CreatedURLAlias(array('urlAlias' => $createdURLAlias));
    }