eZ\Publish\Core\REST\Server\Controller\Location::createLocation PHP Method

createLocation() public method

Creates a new location for object with id $contentId.
public createLocation ( mixed $contentId, Request $request ) : CreatedLocation
$contentId mixed
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\CreatedLocation
    public function createLocation($contentId, Request $request)
    {
        $locationCreateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
        $contentInfo = $this->contentService->loadContentInfo($contentId);
        try {
            $createdLocation = $this->locationService->createLocation($contentInfo, $locationCreateStruct);
        } catch (InvalidArgumentException $e) {
            throw new ForbiddenException($e->getMessage());
        }
        return new Values\CreatedLocation(array('restLocation' => new Values\RestLocation($createdLocation, 0)));
    }