本文整理汇总了PHP中eZ\Publish\API\Repository\LocationService::newLocationCreateStruct方法的典型用法代码示例。如果您正苦于以下问题:PHP LocationService::newLocationCreateStruct方法的具体用法?PHP LocationService::newLocationCreateStruct怎么用?PHP LocationService::newLocationCreateStruct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\LocationService
的用法示例。
在下文中一共展示了LocationService::newLocationCreateStruct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse input structure
*
* @param array $data
* @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
*
* @return \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct
*/
public function parse(array $data, ParsingDispatcher $parsingDispatcher)
{
if (!array_key_exists('ParentLocation', $data) || !is_array($data['ParentLocation'])) {
throw new Exceptions\Parser("Missing or invalid 'ParentLocation' element for LocationCreate.");
}
if (!array_key_exists('_href', $data['ParentLocation'])) {
throw new Exceptions\Parser("Missing '_href' attribute for ParentLocation element in LocationCreate.");
}
$locationHrefParts = explode('/', $this->requestParser->parseHref($data['ParentLocation']['_href'], 'locationPath'));
$locationCreateStruct = $this->locationService->newLocationCreateStruct(array_pop($locationHrefParts));
if (array_key_exists('priority', $data)) {
$locationCreateStruct->priority = (int) $data['priority'];
}
if (array_key_exists('hidden', $data)) {
$locationCreateStruct->hidden = $this->parserTools->parseBooleanValue($data['hidden']);
}
if (array_key_exists('remoteId', $data)) {
$locationCreateStruct->remoteId = $data['remoteId'];
}
if (!array_key_exists('sortField', $data)) {
throw new Exceptions\Parser("Missing 'sortField' element for LocationCreate.");
}
$locationCreateStruct->sortField = $this->parserTools->parseDefaultSortField($data['sortField']);
if (!array_key_exists('sortOrder', $data)) {
throw new Exceptions\Parser("Missing 'sortOrder' element for LocationCreate.");
}
$locationCreateStruct->sortOrder = $this->parserTools->parseDefaultSortOrder($data['sortOrder']);
return $locationCreateStruct;
}
示例2: 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);
}
示例3: createWithoutDraftAction
/**
* Displays and processes a content creation form. Showing the form does not create a draft in the repository.
*
* @param int $contentTypeIdentifier ContentType id to create
* @param string $language Language code to create the content in (eng-GB, ger-DE, ...))
* @param int $parentLocationId Location the content should be a child of
* @param \Symfony\Component\HttpFoundation\Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function createWithoutDraftAction($contentTypeIdentifier, $language, $parentLocationId, Request $request)
{
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($contentTypeIdentifier);
$data = (new ContentCreateMapper())->mapToFormData($contentType, ['mainLanguageCode' => $language, 'parentLocation' => $this->locationService->newLocationCreateStruct($parentLocationId)]);
$form = $this->createForm(ContentEditType::class, $data, ['languageCode' => $language]);
$form->handleRequest($request);
if ($form->isValid()) {
$this->contentActionDispatcher->dispatchFormAction($form, $data, $form->getClickedButton()->getName());
if ($response = $this->contentActionDispatcher->getResponse()) {
return $response;
}
}
return $this->render('EzSystemsRepositoryFormsBundle:Content:content_edit.html.twig', ['form' => $form->createView(), 'languageCode' => $language, 'pagelayout' => $this->pagelayout]);
}
示例4: getLocationCreateStruct
/**
* Creates and prepares location create structure.
*
* @param array $data
* @param int $defaultLocationId
* @return \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct
*/
private function getLocationCreateStruct($data, $defaultLocationId)
{
$parentLocationId = $this->getContentDataParentLocationId($data, $defaultLocationId);
$locationStruct = $this->locationService->newLocationCreateStruct($parentLocationId);
$locationStruct->priority = isset($data['priority']) ? $data['priority'] : 0;
return $locationStruct;
}
示例5: newLocationCreateStruct
/**
* Instantiates a new location create class
*
* @param mixed $parentLocationId the parent under which the new location should be created
*
* @return \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct
*/
public function newLocationCreateStruct($parentLocationId)
{
return $this->service->newLocationCreateStruct($parentLocationId);
}