当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentTypeService::loadContentType方法代码示例

本文整理汇总了PHP中eZ\Publish\API\Repository\ContentTypeService::loadContentType方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentTypeService::loadContentType方法的具体用法?PHP ContentTypeService::loadContentType怎么用?PHP ContentTypeService::loadContentType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\API\Repository\ContentTypeService的用法示例。


在下文中一共展示了ContentTypeService::loadContentType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\User\UserCreateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentType = null;
     if (array_key_exists('ContentType', $data) && is_array($data['ContentType'])) {
         if (!array_key_exists('_href', $data['ContentType'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for ContentType element in UserCreate.");
         }
         $contentType = $this->contentTypeService->loadContentType($this->requestParser->parseHref($data['ContentType']['_href'], 'contentTypeId'));
     }
     if (!array_key_exists('mainLanguageCode', $data)) {
         throw new Exceptions\Parser("Missing 'mainLanguageCode' element for UserCreate.");
     }
     if (!array_key_exists('login', $data)) {
         throw new Exceptions\Parser("Missing 'login' element for UserCreate.");
     }
     if (!array_key_exists('email', $data)) {
         throw new Exceptions\Parser("Missing 'email' element for UserCreate.");
     }
     if (!array_key_exists('password', $data)) {
         throw new Exceptions\Parser("Missing 'password' element for UserCreate.");
     }
     $userCreateStruct = $this->userService->newUserCreateStruct($data['login'], $data['email'], $data['password'], $data['mainLanguageCode'], $contentType);
     if (array_key_exists('Section', $data) && is_array($data['Section'])) {
         if (!array_key_exists('_href', $data['Section'])) {
             throw new Exceptions\Parser("Missing '_href' attribute for Section element in UserCreate.");
         }
         $userCreateStruct->sectionId = $this->requestParser->parseHref($data['Section']['_href'], 'sectionId');
     }
     if (array_key_exists('remoteId', $data)) {
         $userCreateStruct->remoteId = $data['remoteId'];
     }
     if (array_key_exists('enabled', $data)) {
         $userCreateStruct->enabled = $this->parserTools->parseBooleanValue($data['enabled']);
     }
     if (!array_key_exists('fields', $data) || !is_array($data['fields']) || !is_array($data['fields']['field'])) {
         throw new Exceptions\Parser("Missing or invalid 'fields' element for UserCreate.");
     }
     foreach ($data['fields']['field'] as $fieldData) {
         if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for UserCreate.");
         }
         $fieldDefinition = $userCreateStruct->contentType->getFieldDefinition($fieldData['fieldDefinitionIdentifier']);
         if (!$fieldDefinition) {
             throw new Exceptions\Parser("'{$fieldData['fieldDefinitionIdentifier']}' is invalid field definition identifier for '{$userCreateStruct->contentType->identifier}' content type in UserCreate.");
         }
         if (!array_key_exists('fieldValue', $fieldData)) {
             throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in UserCreate.");
         }
         $fieldValue = $this->fieldTypeParser->parseValue($fieldDefinition->fieldTypeIdentifier, $fieldData['fieldValue']);
         $languageCode = null;
         if (array_key_exists('languageCode', $fieldData)) {
             $languageCode = $fieldData['languageCode'];
         }
         $userCreateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
     }
     return $userCreateStruct;
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:65,代码来源:UserCreate.php

示例2: getHandler

 /**
  * Returns form handler to use at $location
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @return \Heliopsis\eZFormsBundle\FormHandler\FormHandlerInterface
  */
 public function getHandler(Location $location)
 {
     $locationContentTypeId = $location->contentInfo->contentTypeId;
     /** @var ContentType $locationContentType */
     $locationContentType = $this->contentTypeService->loadContentType($locationContentTypeId);
     return array_key_exists($locationContentType->identifier, $this->map) ? $this->map[$locationContentType->identifier] : new NullHandler();
 }
开发者ID:heliopsis,项目名称:ezforms-bundle,代码行数:13,代码来源:ContentTypeIdentifierMap.php

示例3: parseFieldValue

 /**
  * Parses the given $value for the field $fieldDefIdentifier in the content
  * identified by $contentInfoId.
  *
  * @param string $contentInfoId
  * @param string $fieldDefIdentifier
  * @param mixed $value
  *
  * @return mixed
  */
 public function parseFieldValue($contentInfoId, $fieldDefIdentifier, $value)
 {
     $contentInfo = $this->contentService->loadContentInfo($contentInfoId);
     $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
     $fieldDefinition = $contentType->getFieldDefinition($fieldDefIdentifier);
     return $this->parseValue($fieldDefinition->fieldTypeIdentifier, $value);
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:17,代码来源:FieldTypeParser.php

示例4: parse

 /**
  * Parse input structure.
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\Core\REST\Server\Values\Version
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentId = $this->requestParser->parseHref($data['VersionInfo']['Content']['_href'], 'contentId');
     $content = $this->contentService->loadContent($contentId, null, $data['VersionInfo']['versionNo']);
     $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     $relations = $this->contentService->loadRelations($content->versionInfo);
     return new VersionValue($content, $contentType, $relations);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:16,代码来源:Version.php

示例5: mapContentInfo

 /**
  * Maps Repository ContentInfo to the Site ContentInfo.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
  * @param string $languageCode
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType|null $contentType
  *
  * @return \Netgen\EzPlatformSiteApi\API\Values\ContentInfo
  */
 public function mapContentInfo(VersionInfo $versionInfo, $languageCode, ContentType $contentType = null)
 {
     $contentInfo = $versionInfo->contentInfo;
     if ($contentType === null) {
         $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
     }
     return new ContentInfo(['name' => $versionInfo->getName($languageCode), 'languageCode' => $languageCode, 'innerContentInfo' => $versionInfo->contentInfo, 'innerContentType' => $contentType]);
 }
开发者ID:netgen,项目名称:ezplatform-site-api,代码行数:17,代码来源:DomainObjectMapper.php

示例6: getForm

 /**
  * @param Location $location
  * @return \Symfony\Component\Form\FormInterface
  * @throws \Heliopsis\eZFormsBundle\Exceptions\UnknownFormException
  */
 public function getForm(Location $location)
 {
     $locationContentTypeId = $location->contentInfo->contentTypeId;
     /** @var ContentType $locationContentType */
     $locationContentType = $this->contentTypeService->loadContentType($locationContentTypeId);
     if (!array_key_exists($locationContentType->identifier, $this->map)) {
         throw new UnknownFormException(sprintf("No form could be mapped to content type identifier '%s'", $locationContentType->identifier));
     }
     return $this->formFactory->create($this->map[$locationContentType->identifier]);
 }
开发者ID:heliopsis,项目名称:ezforms-bundle,代码行数:15,代码来源:ContentTypeIdentifierMap.php

示例7: itContainsAVersionOfContentType

 /**
  * @Given /^it contains a Version of ContentType "([^"]*)"$/
  */
 public function itContainsAVersionOfContentType($contentTypeIdentifier)
 {
     $object = $this->restContext->getResponseObject();
     Assertion::assertInstanceOf('eZ\\Publish\\Core\\REST\\Server\\Values\\Version', $object);
     Assertion::assertEquals($contentTypeIdentifier, $this->contentTypeService->loadContentType($object->content->contentInfo->contentTypeId)->identifier);
     $this->currentContent = $this->contentService->loadContentByVersionInfo($object->content->versionInfo);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:10,代码来源:UserContentContext.php

示例8: assignUserToUserGroup

 /**
  * Assigns the user to a user group
  *
  * @param $userId
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  * @return \eZ\Publish\Core\REST\Server\Values\UserGroupRefList
  */
 public function assignUserToUserGroup($userId)
 {
     $user = $this->userService->loadUser($userId);
     try {
         $userGroupLocation = $this->locationService->loadLocation($this->extractLocationIdFromPath($this->request->query->get('group')));
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     try {
         $userGroup = $this->userService->loadUserGroup($userGroupLocation->contentId);
     } catch (APINotFoundException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     try {
         $this->userService->assignUserToUserGroup($user, $userGroup);
     } catch (InvalidArgumentException $e) {
         throw new Exceptions\ForbiddenException($e->getMessage());
     }
     $userGroups = $this->userService->loadUserGroupsOfUser($user);
     $restUserGroups = array();
     foreach ($userGroups as $userGroup) {
         $userGroupContentInfo = $userGroup->getVersionInfo()->getContentInfo();
         $userGroupLocation = $this->locationService->loadLocation($userGroupContentInfo->mainLocationId);
         $contentType = $this->contentTypeService->loadContentType($userGroupContentInfo->contentTypeId);
         $restUserGroups[] = new Values\RestUserGroup($userGroup, $contentType, $userGroupContentInfo, $userGroupLocation, $this->contentService->loadRelations($userGroup->getVersionInfo()));
     }
     return new Values\UserGroupRefList($restUserGroups, $this->router->generate('ezpublish_rest_loadUserGroupsOfUser', array('userId' => $userId)), $userId);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:36,代码来源:User.php

示例9: visit

 /**
  * Visit struct returned by controllers.
  *
  * @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
  * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
  * @param \eZ\Publish\Core\REST\Server\Values\RestExecutedView $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('View');
     $visitor->setHeader('Content-Type', $generator->getMediaType('View'));
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_views_load', array('viewId' => $data->identifier)));
     $generator->endAttribute('href');
     $generator->startValueElement('identifier', $data->identifier);
     $generator->endValueElement('identifier');
     // BEGIN Query
     $generator->startObjectElement('Query');
     $generator->endObjectElement('Query');
     // END Query
     // BEGIN Result
     $generator->startObjectElement('Result', 'ViewResult');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_views_load_results', array('viewId' => $data->identifier)));
     $generator->endAttribute('href');
     // BEGIN Result metadata
     $generator->startValueElement('count', $data->searchResults->totalCount);
     $generator->endValueElement('count');
     $generator->startValueElement('time', $data->searchResults->time);
     $generator->endValueElement('time');
     $generator->startValueElement('timedOut', $generator->serializeBool($data->searchResults->timedOut));
     $generator->endValueElement('timedOut');
     $generator->startValueElement('maxScore', $data->searchResults->maxScore);
     $generator->endValueElement('maxScore');
     // END Result metadata
     // BEGIN searchHits
     $generator->startHashElement('searchHits');
     $generator->startList('searchHit');
     foreach ($data->searchResults->searchHits as $searchHit) {
         $generator->startObjectElement('searchHit');
         $generator->startAttribute('score', 0);
         $generator->endAttribute('score');
         $generator->startAttribute('index', 0);
         $generator->endAttribute('index');
         $generator->startObjectElement('value');
         // @todo Refactor
         if ($searchHit->valueObject instanceof ApiValues\Content) {
             /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
             $contentInfo = $searchHit->valueObject->contentInfo;
             $valueObject = new RestContentValue($contentInfo, $this->locationService->loadLocation($contentInfo->mainLocationId), $searchHit->valueObject, $this->contentTypeService->loadContentType($contentInfo->contentTypeId), $this->contentService->loadRelations($searchHit->valueObject->getVersionInfo()));
         } elseif ($searchHit->valueObject instanceof ApiValues\Location) {
             $valueObject = $searchHit->valueObject;
         } elseif ($searchHit->valueObject instanceof ApiValues\ContentInfo) {
             $valueObject = new RestContentValue($searchHit->valueObject);
         } else {
             throw new Exceptions\InvalidArgumentException('Unhandled object type');
         }
         $visitor->visitValueObject($valueObject);
         $generator->endObjectElement('value');
         $generator->endObjectElement('searchHit');
     }
     $generator->endList('searchHit');
     $generator->endHashElement('searchHits');
     // END searchHits
     $generator->endObjectElement('Result');
     // END Result
     $generator->endObjectElement('View');
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:66,代码来源:RestExecutedView.php

示例10: processRemoveContentTypeDraft

 public function processRemoveContentTypeDraft(FormActionEvent $event)
 {
     /** @var ContentTypeDraft $contentTypeDraft */
     $contentTypeDraft = $event->getData()->contentTypeDraft;
     $languageCode = $event->getOption('languageCode');
     // Redirect response will be different if we're dealing with an existing ContentType or a newly created one, which has been discarded.
     try {
         // This will throw a NotFoundException if a published version doesn't exist for this ContentType.
         $this->contentTypeService->loadContentType($contentTypeDraft->id);
         $response = $this->generateRedirectResponse($contentTypeDraft, $languageCode);
     } catch (NotFoundException $e) {
         // ContentTypeDraft was newly created, but then discarded.
         // Redirect to the ContentTypeGroup view.
         $response = new FormProcessingDoneResponse($this->router->generate('admin_contenttypeGroupView', ['contentTypeGroupId' => $contentTypeDraft->contentTypeGroups[0]->id]));
     }
     $event->setResponse($response);
     $this->notify('content_type.notification.draft_removed', [], 'content_type');
 }
开发者ID:yed30,项目名称:PlatformUIBundle,代码行数:18,代码来源:ContentTypeFormProcessor.php

示例11: getFieldTypeIdentifier

 /**
  * Returns the field type identifier for $field.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param \eZ\Publish\API\Repository\Values\Content\Field $field
  *
  * @return string
  */
 private function getFieldTypeIdentifier(Content $content, Field $field)
 {
     $contentInfo = $content->getVersionInfo()->getContentInfo();
     $key = $contentInfo->contentTypeId . '  ' . $field->fieldDefIdentifier;
     if (!isset($this->fieldTypeIdentifiers[$key])) {
         $contentType = $this->contentTypeService->loadContentType($contentInfo->contentTypeId);
         $this->fieldTypeIdentifiers[$key] = $contentType->getFieldDefinition($field->fieldDefIdentifier)->fieldTypeIdentifier;
     }
     return $this->fieldTypeIdentifiers[$key];
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:18,代码来源:FieldRenderingExtension.php

示例12: deleteContentTypeAction

 public function deleteContentTypeAction(Request $request, $contentTypeId)
 {
     $contentType = $this->contentTypeService->loadContentType($contentTypeId);
     $deleteForm = $this->createForm(new ContentTypeDeleteType(), ['contentTypeId' => $contentTypeId]);
     $deleteForm->handleRequest($request);
     if ($deleteForm->isValid()) {
         $this->contentTypeService->deleteContentType($contentType);
         $this->notify('content_type.notification.deleted', ['%contentTypeName%' => $contentType->getName($contentType->mainLanguageCode)], 'content_type');
         return $this->redirectToRouteAfterFormPost('admin_contenttypeGroupView', ['contentTypeGroupId' => $contentType->getContentTypeGroups()[0]->id]);
     }
     // Form validation failed. Send errors as notifications.
     foreach ($deleteForm->getErrors(true) as $error) {
         $this->notifyErrorPlural($error->getMessageTemplate(), $error->getMessagePluralization(), $error->getMessageParameters(), 'ezrepoforms_content_type');
     }
     return $this->redirectToRouteAfterFormPost('admin_contenttypeView', ['contentTypeId' => $contentTypeId]);
 }
开发者ID:yed30,项目名称:PlatformUIBundle,代码行数:16,代码来源:ContentTypeController.php

示例13: getImageFieldIdentifier

 /**
  * Return identifier of a field of ezimage type.
  *
  * @param mixed $contentId
  * @param string $language
  * @param bool $related
  *
  * @return string
  */
 private function getImageFieldIdentifier($contentId, $language, $related = false)
 {
     $content = $this->contentService->loadContent($contentId);
     $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     $fieldDefinitions = $this->getFieldDefinitionList();
     $fieldNames = array_flip($fieldDefinitions);
     if (in_array('ezimage', $fieldDefinitions)) {
         return $fieldNames['ezimage'];
     } elseif (in_array('ezobjectrelation', $fieldDefinitions) && !$related) {
         $field = $content->getFieldValue($fieldNames['ezobjectrelation'], $language);
         if (!empty($field->destinationContentId)) {
             return $this->getImageFieldIdentifier($field->destinationContentId, $language, true);
         }
     } else {
         return $this->getConfiguredFieldIdentifier('image', $contentType);
     }
 }
开发者ID:sdaoudi,项目名称:EzSystemsRecommendationBundle,代码行数:26,代码来源:Value.php

示例14: visit

 /**
  * Visit struct returned by controllers
  *
  * @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
  * @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
  * @param \eZ\Publish\Core\REST\Server\Values\RestExecutedView $data
  */
 public function visit(Visitor $visitor, Generator $generator, $data)
 {
     $generator->startObjectElement('View');
     $visitor->setHeader('Content-Type', $generator->getMediaType('View'));
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_getView', array('viewId' => $data->identifier)));
     $generator->endAttribute('href');
     $generator->startValueElement('identifier', $data->identifier);
     $generator->endValueElement('identifier');
     // BEGIN Query
     $generator->startObjectElement('Query');
     $generator->endObjectElement('Query');
     // END Query
     // BEGIN Result
     $generator->startObjectElement('Result', 'ViewResult');
     $generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadViewResults', array('viewId' => $data->identifier)));
     $generator->endAttribute('href');
     // BEGIN searchHits
     $generator->startHashElement('searchHits');
     $generator->startList('searchHit');
     foreach ($data->searchResults->searchHits as $searchHit) {
         $generator->startObjectElement('searchHit');
         $generator->startAttribute('score', 0);
         $generator->endAttribute('score');
         $generator->startAttribute('index', 0);
         $generator->endAttribute('index');
         $generator->startObjectElement('value');
         /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
         $contentInfo = $searchHit->valueObject->contentInfo;
         $restContent = new RestContentValue($contentInfo, $this->locationService->loadLocation($contentInfo->mainLocationId), $searchHit->valueObject, $this->contentTypeService->loadContentType($contentInfo->contentTypeId), $this->contentService->loadRelations($searchHit->valueObject->getVersionInfo()));
         $visitor->visitValueObject($restContent);
         $generator->endObjectElement('value');
         $generator->endObjectElement('searchHit');
     }
     $generator->endList('searchHit');
     $generator->endHashElement('searchHits');
     // END searchHits
     $generator->endObjectElement('Result');
     // END Result
     $generator->endObjectElement('View');
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:47,代码来源:RestExecutedView.php

示例15: unlinkContentTypeFromGroup

 /**
  * Removes the given group from the content type and returns the updated group list
  *
  * @param $contentTypeId
  * @param $contentTypeGroupId
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\NotFoundException
  * @return \eZ\Publish\Core\REST\Server\Values\ContentTypeGroupRefList
  */
 public function unlinkContentTypeFromGroup($contentTypeId, $contentTypeGroupId)
 {
     $contentType = $this->contentTypeService->loadContentType($contentTypeId);
     $contentTypeGroup = $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId);
     $existingContentTypeGroups = $contentType->getContentTypeGroups();
     $contentTypeInGroup = false;
     foreach ($existingContentTypeGroups as $existingGroup) {
         if ($existingGroup->id == $contentTypeGroup->id) {
             $contentTypeInGroup = true;
             break;
         }
     }
     if (!$contentTypeInGroup) {
         throw new Exceptions\NotFoundException('Content type is not in the given group');
     }
     if (count($existingContentTypeGroups) == 1) {
         throw new ForbiddenException('Content type cannot be unlinked from the only remaining group');
     }
     $this->contentTypeService->unassignContentTypeGroup($contentType, $contentTypeGroup);
     $contentType = $this->contentTypeService->loadContentType($contentTypeId);
     return new Values\ContentTypeGroupRefList($contentType, $contentType->getContentTypeGroups());
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:32,代码来源:ContentType.php


注:本文中的eZ\Publish\API\Repository\ContentTypeService::loadContentType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。