本文整理汇总了PHP中eZ\Publish\API\Repository\ContentTypeService::loadContentTypeDraft方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentTypeService::loadContentTypeDraft方法的具体用法?PHP ContentTypeService::loadContentTypeDraft怎么用?PHP ContentTypeService::loadContentTypeDraft使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\ContentTypeService
的用法示例。
在下文中一共展示了ContentTypeService::loadContentTypeDraft方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processAddFieldDefinition
public function processAddFieldDefinition(FormActionEvent $event)
{
// Reload the draft, to make sure we include any changes made in the current form submit
$contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($event->getData()->contentTypeDraft->id);
$fieldTypeIdentifier = $event->getForm()->get('fieldTypeSelection')->getData();
$maxFieldPos = 0;
foreach ($contentTypeDraft->fieldDefinitions as $existingFieldDef) {
if ($existingFieldDef->position > $maxFieldPos) {
$maxFieldPos = $existingFieldDef->position;
}
}
$fieldDefCreateStruct = new FieldDefinitionCreateStruct(['fieldTypeIdentifier' => $fieldTypeIdentifier, 'identifier' => sprintf('new_%s_%d', $fieldTypeIdentifier, count($contentTypeDraft->fieldDefinitions) + 1), 'names' => [$event->getOption('languageCode') => 'New FieldDefinition'], 'position' => $maxFieldPos + 1]);
$this->contentTypeService->addFieldDefinition($contentTypeDraft, $fieldDefCreateStruct);
}
示例2: 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]);
}
示例3: getFieldDefinition
/**
* Returns field definition by 'typeFieldDefinitionDraft' pattern URL.
*
* Assumes given $data array has '__url' element set.
* @todo depends on temporary solution to give parser access to the URL
* @see \eZ\Publish\Core\REST\Server\Controller\ContentType::updateFieldDefinition
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
*
* @param array $data
*
* @return \eZ\Publish\API\Repository\Values\ContentType\FieldDefinition
*/
protected function getFieldDefinition(array $data)
{
$contentTypeId = $this->requestParser->parseHref($data["__url"], 'contentTypeId');
$fieldDefinitionId = $this->requestParser->parseHref($data["__url"], 'fieldDefinitionId');
$contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
foreach ($contentTypeDraft->getFieldDefinitions() as $fieldDefinition) {
if ($fieldDefinition->id == $fieldDefinitionId) {
return $fieldDefinition;
}
}
throw new Exceptions\NotFoundException("Field definition not found: '{$data["__url"]}'.");
}
示例4: loadContentTypeDraft
/**
* Get a Content Type object draft by id
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If the content type draft owned by the current user can not be found
*
* @param mixed $contentTypeId
*
* @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
*/
public function loadContentTypeDraft($contentTypeId)
{
return $this->service->loadContentTypeDraft($contentTypeId);
}
示例5: deleteContentTypeDraft
/**
* The given content type draft is deleted
*
* @param $contentTypeId
*
* @return \eZ\Publish\Core\REST\Server\Values\NoContent
*/
public function deleteContentTypeDraft($contentTypeId)
{
$contentTypeDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
$this->contentTypeService->deleteContentType($contentTypeDraft);
return new Values\NoContent();
}