本文整理汇总了PHP中eZ\Publish\API\Repository\ContentTypeService::createContentTypeDraft方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentTypeService::createContentTypeDraft方法的具体用法?PHP ContentTypeService::createContentTypeDraft怎么用?PHP ContentTypeService::createContentTypeDraft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\ContentTypeService
的用法示例。
在下文中一共展示了ContentTypeService::createContentTypeDraft方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateFieldDefinition
public function updateFieldDefinition($identifier, FieldDefinitionUpdateStruct $fieldDefinitionUpdateStruct)
{
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($this->currentContentType);
$this->contentTypeService->updateFieldDefinition($contentTypeDraft, $this->currentContentType->getFieldDefinition($identifier), $fieldDefinitionUpdateStruct);
$this->contentTypeService->publishContentTypeDraft($contentTypeDraft);
$this->currentContentType = $this->contentTypeService->loadContentTypeByIdentifier($this->currentContentType->identifier);
}
示例2: getUpdatedDraft
/**
* Update content type definition and returns a draft
*
* @param array $data
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
*/
private function getUpdatedDraft(array &$data)
{
$contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['identifier']);
$draft = $this->contentTypeService->createContentTypeDraft($contentType);
// Update content type
$struct = $this->contentTypeService->newContentTypeUpdateStruct($data);
$this->fillValueObject($struct, $data);
$diff = $this->diff->diff($contentType->fieldDefinitions, $data['field_definitions'], 'identifier');
// @todo: introduce field updates (now only remove and add are supported)
$this->updateDraftFields($draft, $diff, $data);
$this->contentTypeService->updateContentTypeDraft($draft, $struct);
return $draft;
}
示例3: updateContentTypeAction
public function updateContentTypeAction(Request $request, $contentTypeId, $languageCode = null)
{
$languageCode = $languageCode ?: $this->prioritizedLanguages[0];
// First try to load the draft.
// If it doesn't exist, create it.
try {
$contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
} catch (NotFoundException $e) {
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($this->contentTypeService->loadContentType($contentTypeId));
}
$contentTypeData = (new ContentTypeDraftMapper())->mapToFormData($contentTypeDraft);
$form = $this->createForm('ezrepoforms_contenttype_update', $contentTypeData, ['languageCode' => $languageCode]);
$actionUrl = $this->generateUrl('admin_contenttypeUpdate', ['contentTypeId' => $contentTypeId, 'languageCode' => $languageCode]);
// Synchronize form and data.
$form->handleRequest($request);
$hasErrors = false;
if ($form->isValid()) {
$this->contentTypeActionDispatcher->dispatchFormAction($form, $contentTypeData, $form->getClickedButton() ? $form->getClickedButton()->getName() : null, ['languageCode' => $languageCode]);
if ($response = $this->contentTypeActionDispatcher->getResponse()) {
return $response;
}
return $this->redirectAfterFormPost($actionUrl);
} elseif ($form->isSubmitted()) {
$hasErrors = true;
}
return $this->render('eZPlatformUIBundle:ContentType:update_content_type.html.twig', ['form' => $form->createView(), 'action_url' => $actionUrl, 'contentTypeName' => $contentTypeDraft->getName($languageCode), 'contentTypeDraft' => $contentTypeDraft, 'modifier' => $this->userService->loadUser($contentTypeDraft->modifierId), 'languageCode' => $languageCode, 'hasErrors' => $hasErrors]);
}
示例4: createContentTypeDraft
/**
* Creates a draft and updates it with the given data
*
* @param $contentTypeId
*
* @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
* @return \eZ\Publish\Core\REST\Server\Values\CreatedContentType
*/
public function createContentTypeDraft($contentTypeId, Request $request)
{
$contentType = $this->contentTypeService->loadContentType($contentTypeId);
try {
$contentTypeDraft = $this->contentTypeService->createContentTypeDraft($contentType);
} catch (BadStateException $e) {
throw new ForbiddenException($e->getMessage());
}
$contentTypeUpdateStruct = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
try {
$this->contentTypeService->updateContentTypeDraft($contentTypeDraft, $contentTypeUpdateStruct);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
}
return new Values\CreatedContentType(array('contentType' => new Values\RestContentType($this->contentTypeService->loadContentTypeDraft($contentTypeDraft->id))));
}
示例5: createContentTypeDraft
/**
* Creates a draft from an existing content type.
*
* This is a complete copy of the content
* type which has the state STATUS_DRAFT.
*
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit a content type
* @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If there is already a draft assigned to another user
*
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
*
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
*/
public function createContentTypeDraft(ContentType $contentType)
{
$returnValue = $this->service->createContentTypeDraft($contentType);
$this->signalDispatcher->emit(new CreateContentTypeDraftSignal(array('contentTypeId' => $contentType->id)));
return $returnValue;
}