本文整理汇总了PHP中eZ\Publish\API\Repository\LocationService::createLocation方法的典型用法代码示例。如果您正苦于以下问题:PHP LocationService::createLocation方法的具体用法?PHP LocationService::createLocation怎么用?PHP LocationService::createLocation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\LocationService
的用法示例。
在下文中一共展示了LocationService::createLocation方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPostCategories
public function setPostCategories($postId, Request $request)
{
$this->login($request->request->get('username'), $request->request->get('password'));
// @todo Replace categories instead of adding
$contentInfo = $this->contentService->loadContentInfo($postId);
foreach ($request->request->get('categories') as $category) {
$this->locationService->createLocation($contentInfo, $this->locationService->newLocationCreateStruct($category['categoryId']));
}
return new Response(true);
}
示例2: createLocation
/**
* Creates a new location for object with id $contentId.
*
* @param mixed $contentId
*
* @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
*
* @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)));
}
示例3: createLocation
/**
* Creates the new $location in the content repository for the given content
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to create this location
* @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the content is already below the specified parent
* or the parent is a sub location of the location of the content
* or if set the remoteId exists already
*
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
*
* @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $locationCreateStruct
*
* @return \eZ\Publish\API\Repository\Values\Content\Location the newly created Location
*
*/
public function createLocation(ContentInfo $contentInfo, LocationCreateStruct $locationCreateStruct)
{
$returnValue = $this->service->createLocation($contentInfo, $locationCreateStruct);
$this->signalDispatcher->emit(new CreateLocationSignal(array('contentId' => $contentInfo->id, 'locationId' => $returnValue->id)));
return $returnValue;
}