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


PHP ContentService::loadContentInfo方法代码示例

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


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

示例1: 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

示例2: convert

 /**
  * Converts internal links (ezcontent:// and ezlocation://) to URLs.
  *
  * @param \DOMDocument $document
  *
  * @return \DOMDocument
  */
 public function convert(DOMDocument $document)
 {
     $document = clone $document;
     $xpath = new DOMXPath($document);
     $xpath->registerNamespace("docbook", "http://docbook.org/ns/docbook");
     $linkAttributeExpression = "starts-with( @xlink:href, 'ezlocation://' ) or starts-with( @xlink:href, 'ezcontent://' )";
     $xpathExpression = "//docbook:link[{$linkAttributeExpression}]|//docbook:ezlink";
     /** @var \DOMElement $link */
     foreach ($xpath->query($xpathExpression) as $link) {
         // Set resolved href to number character as a default if it can't be resolved
         $hrefResolved = "#";
         $href = $link->getAttribute("xlink:href");
         $location = null;
         preg_match("~^(.+://)?([^#]*)?(#.*|\\s*)?\$~", $href, $matches);
         list(, $scheme, $id, $fragment) = $matches;
         if ($scheme === "ezcontent://") {
             try {
                 $contentInfo = $this->contentService->loadContentInfo($id);
                 $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
                 $hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
             } catch (APINotFoundException $e) {
                 if ($this->logger) {
                     $this->logger->warning("While generating links for richtext, could not locate " . "Content object with ID " . $id);
                 }
             } catch (APIUnauthorizedException $e) {
                 if ($this->logger) {
                     $this->logger->notice("While generating links for richtext, unauthorized to load " . "Content object with ID " . $id);
                 }
             }
         } else {
             if ($scheme === "ezlocation://") {
                 try {
                     $location = $this->locationService->loadLocation($id);
                     $hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
                 } catch (APINotFoundException $e) {
                     if ($this->logger) {
                         $this->logger->warning("While generating links for richtext, could not locate " . "Location with ID " . $id);
                     }
                 } catch (APIUnauthorizedException $e) {
                     if ($this->logger) {
                         $this->logger->notice("While generating links for richtext, unauthorized to load " . "Location with ID " . $id);
                     }
                 }
             } else {
                 $hrefResolved = $href;
             }
         }
         $hrefAttributeName = "xlink:href";
         // For embeds set the resolved href to the separate attribute
         // Original href needs to be preserved in order to generate link parameters
         // This will need to change with introduction of UrlService and removal of URL link
         // resolving in external storage
         if ($link->localName === "ezlink") {
             $hrefAttributeName = "href_resolved";
         }
         $link->setAttribute($hrefAttributeName, $hrefResolved);
     }
     return $document;
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:66,代码来源:Link.php

示例3: renderForContentAction

 /**
  * Renders the comments list for content with id $contentId
  * Comment form might also be included
  *
  * @param mixed $contentId
  */
 public function renderForContentAction( $contentId )
 {
     return new Response(
         $this->commentsRenderer->renderForContent(
             $this->contentService->loadContentInfo( $contentId ),
             $this->request
         )
     );
 }
开发者ID:ataxel,项目名称:tp,代码行数:15,代码来源:CommentsRendererController.php

示例4: 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);
 }
开发者ID:bdunogier,项目名称:wordpressapibundle,代码行数:10,代码来源:DefaultController.php

示例5: purgeForContent

 public function purgeForContent($contentId)
 {
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     $event = new ContentCacheClearEvent($contentInfo);
     $this->eventDispatcher->dispatch(MVCEvents::CACHE_CLEAR_CONTENT, $event);
     $locationIds = [];
     foreach ($event->getLocationsToClear() as $location) {
         $locationIds[] = $location->id;
     }
     $this->purgeClient->purge(array_unique($locationIds));
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:11,代码来源:InstantCachePurger.php

示例6: purgeForContent

 /**
  * {@inheritdoc}
  */
 public function purgeForContent($contentId, $locationIds = [])
 {
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     // Can only gather relevant locations using ContentCacheClearEvent on published content
     if ($contentInfo->published) {
         $event = new ContentCacheClearEvent($contentInfo);
         $this->eventDispatcher->dispatch(MVCEvents::CACHE_CLEAR_CONTENT, $event);
         foreach ($event->getLocationsToClear() as $location) {
             $locationIds[] = $location->id;
         }
     }
     $this->purgeClient->purge(array_unique($locationIds));
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:16,代码来源:InstantCachePurger.php

示例7: getPreviewLocation

 /**
  * Returns a valid Location object for $contentId.
  * Will either load mainLocationId (if available) or build a virtual Location object.
  *
  * @param mixed $contentId
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location|null Null when content does not have location
  */
 public function getPreviewLocation($contentId)
 {
     // contentInfo must be reloaded as content is not published yet (e.g. no mainLocationId)
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     // mainLocationId already exists, content has been published at least once.
     if ($contentInfo->mainLocationId) {
         $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
     } else {
         // @todo In future releases this will be a full draft location when this feature
         // is implemented. Or it might return null when content does not have location,
         // but for now we can't detect that so we return a virtual draft location
         $location = new Location(array('contentInfo' => $contentInfo, 'status' => Location::STATUS_DRAFT));
     }
     return $location;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:23,代码来源:ContentPreviewHelper.php

示例8: setObjectStatesForContent

 /**
  * Updates object states of content
  * An object state in the input overrides the state of the object state group.
  *
  * @param $contentId
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  *
  * @return \eZ\Publish\Core\REST\Common\Values\ContentObjectStates
  */
 public function setObjectStatesForContent($contentId, Request $request)
 {
     $newObjectStates = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
     $countByGroups = array();
     foreach ($newObjectStates as $newObjectState) {
         $groupId = (int) $newObjectState->groupId;
         if (array_key_exists($groupId, $countByGroups)) {
             ++$countByGroups[$groupId];
         } else {
             $countByGroups[$groupId] = 1;
         }
     }
     foreach ($countByGroups as $groupId => $count) {
         if ($count > 1) {
             throw new ForbiddenException("Multiple object states provided for group with ID {$groupId}");
         }
     }
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     $contentObjectStates = array();
     foreach ($newObjectStates as $newObjectState) {
         $objectStateGroup = $this->objectStateService->loadObjectStateGroup($newObjectState->groupId);
         $this->objectStateService->setContentState($contentInfo, $objectStateGroup, $newObjectState->objectState);
         $contentObjectStates[(int) $objectStateGroup->id] = $newObjectState;
     }
     return new ContentObjectStates($contentObjectStates);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:36,代码来源:ObjectState.php

示例9: generate

 /**
  * Generates a URL for a location, from the given parameters.
  *
  * It is possible to directly pass a Location object as the route name, as the ChainRouter allows it through ChainedRouterInterface.
  *
  * If $name is a route name, the "location" key in $parameters must be set to a valid eZ\Publish\API\Repository\Values\Content\Location object.
  * "locationId" can also be provided.
  *
  * If the generator is not able to generate the url, it must throw the RouteNotFoundException
  * as documented below.
  *
  * @see UrlAliasRouter::supports()
  *
  * @param string|\eZ\Publish\API\Repository\Values\Content\Location $name The name of the route or a Location instance
  * @param mixed $parameters An array of parameters
  * @param int $referenceType The type of reference to be generated (one of the constants)
  *
  * @throws \LogicException
  * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException
  * @throws \InvalidArgumentException
  *
  * @return string The generated URL
  *
  * @api
  */
 public function generate($name, $parameters = array(), $referenceType = UrlGeneratorInterface::ABSOLUTE_PATH)
 {
     // Direct access to Location
     if ($name instanceof Location) {
         return $this->generator->generate($name, $parameters, $referenceType);
     }
     // Normal route name
     if ($name === self::URL_ALIAS_ROUTE_NAME) {
         if (isset($parameters['location']) || isset($parameters['locationId'])) {
             // Check if location is a valid Location object
             if (isset($parameters['location']) && !$parameters['location'] instanceof Location) {
                 throw new LogicException("When generating an UrlAlias route, 'location' parameter must be a valid eZ\\Publish\\API\\Repository\\Values\\Content\\Location.");
             }
             $location = isset($parameters['location']) ? $parameters['location'] : $this->locationService->loadLocation($parameters['locationId']);
             unset($parameters['location'], $parameters['locationId'], $parameters['viewType'], $parameters['layout']);
             return $this->generator->generate($location, $parameters, $referenceType);
         }
         if (isset($parameters['contentId'])) {
             $contentInfo = $this->contentService->loadContentInfo($parameters['contentId']);
             unset($parameters['contentId'], $parameters['viewType'], $parameters['layout']);
             if (empty($contentInfo->mainLocationId)) {
                 throw new LogicException('Cannot generate an UrlAlias route for content without main location.');
             }
             return $this->generator->generate($this->locationService->loadLocation($contentInfo->mainLocationId), $parameters, $referenceType);
         }
         throw new InvalidArgumentException("When generating an UrlAlias route, either 'location', 'locationId' or 'contentId' must be provided.");
     }
     throw new RouteNotFoundException('Could not match route');
 }
开发者ID:kuborgh,项目名称:ezpublish-kernel,代码行数:54,代码来源:UrlAliasRouter.php

示例10: getPreviewLocation

    /**
     * Returns a valid Location object for $contentId.
     * Will either load mainLocationId (if available) or build a virtual Location object.
     *
     * @param mixed $contentId
     *
     * @return \eZ\Publish\API\Repository\Values\Content\Location|null Null when content does not have location
     */
    public function getPreviewLocation( $contentId )
    {
        // contentInfo must be reloaded as content is not published yet (e.g. no mainLocationId)
        $contentInfo = $this->contentService->loadContentInfo( $contentId );
        // mainLocationId already exists, content has been published at least once.
        if ( $contentInfo->mainLocationId )
        {
            $location = $this->locationService->loadLocation( $contentInfo->mainLocationId );
        }
        // New Content, never published, create a virtual location object.
        else
        {
            // @todo In future releases this will be a full draft location when this feature
            // is implemented. Or it might return null when content does not have location,
            // but for now we can't detect that so we return a virtual draft location
            $location = new Location(
                array(
                    // Faking using root locationId
                    'id' => $this->configResolver->getParameter( 'content.tree_root.location_id' ),
                    'contentInfo' => $contentInfo,
                    'status' => Location::STATUS_DRAFT
                )
            );
        }

        return $location;
    }
开发者ID:ataxel,项目名称:tp,代码行数:35,代码来源:ContentPreviewHelper.php

示例11: convert

 /**
  * Converts internal links (eznode:// and ezobject://) to URLs.
  *
  * @param \DOMDocument $xmlDoc
  *
  * @return string|null
  */
 public function convert(DOMDocument $xmlDoc)
 {
     $xpath = new DOMXPath($xmlDoc);
     $elements = $xpath->query('//link|//embed|//embed-inline');
     /** @var \DOMElement $element */
     foreach ($elements as $element) {
         $location = null;
         if ($this->elementHasAttribute($element, 'object_id')) {
             try {
                 $contentInfo = $this->contentService->loadContentInfo($this->getElementAttribute($element, 'object_id'));
                 $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
             } catch (APINotFoundException $e) {
                 if ($this->logger) {
                     $this->logger->warning('While generating links for xmltext, could not locate ' . 'Content object with ID ' . $this->getElementAttribute($element, 'object_id'));
                 }
             } catch (APIUnauthorizedException $e) {
                 if ($this->logger) {
                     $this->logger->notice('While generating links for xmltext, unauthorized to load ' . 'Content object with ID ' . $this->getElementAttribute($element, 'object_id'));
                 }
             }
         }
         if ($this->elementHasAttribute($element, 'node_id')) {
             try {
                 $location = $this->locationService->loadLocation($this->getElementAttribute($element, 'node_id'));
             } catch (APINotFoundException $e) {
                 if ($this->logger) {
                     $this->logger->warning('While generating links for xmltext, could not locate ' . 'Location with ID ' . $this->getElementAttribute($element, 'node_id'));
                 }
             } catch (APIUnauthorizedException $e) {
                 if ($this->logger) {
                     $this->logger->notice('While generating links for xmltext, unauthorized to load ' . 'Location with ID ' . $this->getElementAttribute($element, 'node_id'));
                 }
             }
         }
         if ($location !== null) {
             $element->setAttribute('url', $this->urlAliasRouter->generate($location));
         }
         // Copy temporary URL if it exists and is not set at this point
         if (!$element->hasAttribute('url') && $element->hasAttribute(EmbedLinking::TEMP_PREFIX . 'url')) {
             $element->setAttribute('url', $element->getAttribute(EmbedLinking::TEMP_PREFIX . 'url'));
         }
         if ($this->elementHasAttribute($element, 'anchor_name')) {
             $element->setAttribute('url', $element->getAttribute('url') . '#' . $this->getElementAttribute($element, 'anchor_name'));
         }
     }
 }
开发者ID:xcorp1986,项目名称:ezpublish-kernel,代码行数:53,代码来源:EzLinkToHtml5.php

示例12: loadMainLocation

 /**
  * Loads the main location for $contentId
  *
  * If the content does not have a location (yet), but has a Location draft, it is returned instead.
  * Location drafts do not have an id (it is set to null), and can be tested using the isDraft() method.
  *
  * If the content doesn't have a location nor a location draft, null is returned.
  *
  * @param mixed $contentInfo
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location|null
  */
 public function loadMainLocation($contentId)
 {
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     // mainLocationId already exists, content has been published at least once.
     if ($contentInfo->mainLocationId) {
         $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
     } else {
         // @todo In future releases this will be a full draft location when this feature
         // is implemented. Or it might return null when content does not have location,
         // but for now we can't detect that so we return a virtual draft location
         $parentLocations = $this->locationHandler->loadParentLocationsForDraftContent($contentInfo->id);
         if (count($parentLocations) === 0) {
             return null;
         }
         $location = new Location(array('contentInfo' => $contentInfo, 'status' => Location::STATUS_DRAFT, 'parentLocationId' => $parentLocations[0]->id, 'depth' => $parentLocations[0]->depth + 1));
     }
     return $location;
 }
开发者ID:Jenkosama,项目名称:ezpublish-kernel,代码行数:30,代码来源:PreviewLocationProvider.php

示例13: loadLocationsForContent

 /**
  * Loads all locations for content object.
  *
  * @param mixed $contentId
  *
  * @return \eZ\Publish\Core\REST\Server\Values\LocationList
  */
 public function loadLocationsForContent($contentId, Request $request)
 {
     $restLocations = array();
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     foreach ($this->locationService->loadLocations($contentInfo) as $location) {
         $restLocations[] = new Values\RestLocation($location, $this->locationService->getLocationChildCount($location));
     }
     return new Values\CachedValue(new Values\LocationList($restLocations, $request->getPathInfo()), array('locationId' => $contentInfo->mainLocationId));
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:16,代码来源:Location.php

示例14: loadMainLocation

 /**
  * Loads the main location for $contentId.
  *
  * If the content does not have a location (yet), but has a Location draft, it is returned instead.
  * Location drafts do not have an id (it is set to null), and can be tested using the isDraft() method.
  *
  * If the content doesn't have a location nor a location draft, null is returned.
  *
  * @param mixed $contentId
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location|null
  */
 public function loadMainLocation($contentId)
 {
     $location = null;
     $contentInfo = $this->contentService->loadContentInfo($contentId);
     // mainLocationId already exists, content has been published at least once.
     if ($contentInfo->mainLocationId) {
         $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
     } elseif (!$contentInfo->published) {
         // New Content, never published, create a virtual location object.
         // In cases content is missing locations this will return empty array
         $parentLocations = $this->locationHandler->loadParentLocationsForDraftContent($contentInfo->id);
         if (empty($parentLocations)) {
             return null;
         }
         $location = new Location(array('contentInfo' => $contentInfo, 'status' => Location::STATUS_DRAFT, 'parentLocationId' => $parentLocations[0]->id, 'depth' => $parentLocations[0]->depth + 1, 'pathString' => $parentLocations[0]->pathString . '/x'));
     }
     return $location;
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:30,代码来源:PreviewLocationProvider.php

示例15: getContentTypeId

 /**
  * Gets ContentType ID based on $contentId.
  *
  * @param mixed $contentId
  *
  * @return int|null
  */
 protected function getContentTypeId($contentId)
 {
     $contentTypeId = null;
     try {
         $contentTypeId = $this->contentService->loadContentInfo($contentId)->contentTypeId;
     } catch (\Exception $e) {
     }
     return $contentTypeId;
 }
开发者ID:sdaoudi,项目名称:EzSystemsRecommendationBundle,代码行数:16,代码来源:YooChooseNotifier.php


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