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


PHP ContentService::loadContent方法代码示例

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


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

示例1: previewContentAction

    public function previewContentAction( $contentId, $versionNo, $language, $siteAccessName = null )
    {
        try
        {
            $content = $this->contentService->loadContent( $contentId, array( $language ), $versionNo );
            $location = $this->previewHelper->getPreviewLocation( $contentId );
        }
        catch ( UnauthorizedException $e )
        {
            throw new AccessDeniedException();
        }

        if ( !$this->securityContext->isGranted( new AuthorizationAttribute( 'content', 'versionread', array( 'valueObject' => $content ) ) ) )
        {
            throw new AccessDeniedException();
        }

        $siteAccess = $this->previewHelper->getOriginalSiteAccess();
        // Only switch if $siteAccessName is set and different from original
        if ( $siteAccessName !== null && $siteAccessName !== $siteAccess->name )
        {
            $siteAccess = $this->previewHelper->changeConfigScope( $siteAccessName );
        }

        $response = $this->kernel->handle(
            $this->getForwardRequest( $location, $content, $siteAccess ),
            HttpKernelInterface::SUB_REQUEST
        );
        $response->headers->remove( 'cache-control' );
        $response->headers->remove( 'expires' );

        $this->previewHelper->restoreConfigScope();

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

示例2: findNodes

 public function findNodes(LocationQuery $query)
 {
     $searchResult = $this->searchService->findLocations($query, ['languages' => $this->prioritizedLanguages, 'useAlwaysAvailable' => $this->useAlwaysAvailable]);
     foreach ($searchResult->searchHits as $searchHit) {
         /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */
         $location = $searchHit->valueObject;
         $searchHit->valueObject = $this->domainObjectMapper->mapNode($location, $this->contentService->loadContent($location->contentInfo->id, [$searchHit->matchedTranslation], $location->contentInfo->currentVersionNo), $searchHit->matchedTranslation);
     }
     return $searchResult;
 }
开发者ID:netgen,项目名称:ezplatform-site-api,代码行数:10,代码来源:FindService.php

示例3: redirectToContentDownloadAction

 /**
  * Used by the REST API to reference downloadable files.
  * It redirects (permanently) to the standard ez_content_download route, based on the language of the field
  * passed as an argument, using the language switcher.
  *
  * @param mixed $contentId
  * @param int $fieldId
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function redirectToContentDownloadAction($contentId, $fieldId, Request $request)
 {
     $content = $this->contentService->loadContent($contentId);
     $field = $this->findFieldInContent($fieldId, $content);
     $params = array('content' => $content, 'fieldIdentifier' => $field->fieldDefIdentifier, 'language' => $field->languageCode);
     if ($request->query->has('version')) {
         $params['version'] = $request->query->get('version');
     }
     $downloadUrl = $this->router->generate($this->routeReferenceGenerator->generate('ez_content_download', $params));
     return new RedirectResponse($downloadUrl, 301);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:22,代码来源:DownloadRedirectionController.php

示例4: downloadBinaryFileAction

 /**
  * @param mixed $contentId ID of a valid Content
  * @param string $fieldIdentifier Field Definition identifier of the Field the file must be downloaded from
  * @param string $filename
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \eZ\Bundle\EzPublishIOBundle\BinaryStreamResponse
  */
 public function downloadBinaryFileAction($contentId, $fieldIdentifier, $filename, Request $request)
 {
     if ($request->query->has('version')) {
         $content = $this->contentService->loadContent($contentId, null, $request->query->get('version'));
     } else {
         $content = $this->contentService->loadContent($contentId);
     }
     $field = $this->translationHelper->getTranslatedField($content, $fieldIdentifier, $request->query->has('inLanguage') ? $request->query->get('inLanguage') : null);
     if (!$field instanceof Field) {
         throw new InvalidArgumentException("'{$fieldIdentifier}' field not present on content #{$content->contentInfo->id} '{$content->contentInfo->name}'");
     }
     $response = new BinaryStreamResponse($this->ioService->loadBinaryFile($field->value->id), $this->ioService);
     $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);
     return $response;
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:23,代码来源:DownloadController.php

示例5: getSiteNode

 /**
  * Returns Site Node object for the given Repository $location.
  *
  * @throws \Netgen\EzPlatformSiteApi\Core\Site\Exceptions\TranslationNotMatchedException
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  *
  * @return \Netgen\EzPlatformSiteApi\API\Values\Node
  */
 private function getSiteNode(APILocation $location)
 {
     $versionInfo = $this->contentService->loadVersionInfoById($location->contentInfo->id);
     $languageCode = $this->getLanguage($versionInfo->languageCodes, $versionInfo->contentInfo->mainLanguageCode, $versionInfo->contentInfo->alwaysAvailable);
     if ($languageCode === null) {
         throw new TranslationNotMatchedException($versionInfo->contentInfo->id, $this->getContext($versionInfo));
     }
     return $this->domainObjectMapper->mapNode($location, $this->contentService->loadContent($location->contentInfo->id, [$languageCode], $location->contentInfo->currentVersionNo), $languageCode);
 }
开发者ID:netgen,项目名称:ezplatform-site-api,代码行数:18,代码来源:LoadService.php

示例6: previewContentAction

    /**
     * @throws NotImplementedException If Content is missing location as this is not supported in current version
     */
    public function previewContentAction(Request $request, $contentId, $versionNo, $language, $siteAccessName = null)
    {
        $this->previewHelper->setPreviewActive(true);
        try {
            $content = $this->contentService->loadContent($contentId, array($language), $versionNo);
            $location = $this->locationProvider->loadMainLocation($contentId);
            if (!$location instanceof Location) {
                throw new NotImplementedException('Preview for content without locations');
            }
            $this->previewHelper->setPreviewedContent($content);
            $this->previewHelper->setPreviewedLocation($location);
        } catch (UnauthorizedException $e) {
            throw new AccessDeniedException();
        }
        if (!$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'versionread', array('valueObject' => $content)))) {
            throw new AccessDeniedException();
        }
        $siteAccess = $this->previewHelper->getOriginalSiteAccess();
        // Only switch if $siteAccessName is set and different from original
        if ($siteAccessName !== null && $siteAccessName !== $siteAccess->name) {
            $siteAccess = $this->previewHelper->changeConfigScope($siteAccessName);
        }
        try {
            $response = $this->kernel->handle($this->getForwardRequest($location, $content, $siteAccess, $request, $language), HttpKernelInterface::SUB_REQUEST, false);
        } catch (\Exception $e) {
            if ($location->isDraft() && $this->controllerChecker->usesCustomController($content, $location)) {
                // @todo This should probably be an exception that embeds the original one
                $message = <<<EOF
<p>The view that rendered this location draft uses a custom controller, and resulted in a fatal error.</p>
<p>Location View is deprecated, as it causes issues with preview, such as an empty location id when previewing the first version of a content.</p>
EOF;
                throw new Exception($message, 0, $e);
            } else {
                throw $e;
            }
        }
        $response->headers->remove('cache-control');
        $response->headers->remove('expires');
        $this->previewHelper->restoreConfigScope();
        $this->previewHelper->setPreviewActive(false);
        return $response;
    }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:45,代码来源:PreviewController.php

示例7: publishAliases

 /**
  * Publishes URL aliases in all languages for the given parameters.
  *
  * @throws \Exception
  *
  * @param int|string $locationId
  * @param int|string $parentLocationId
  * @param int|string $contentId
  *
  * @return int
  */
 protected function publishAliases($locationId, $parentLocationId, $contentId)
 {
     $content = $this->contentService->loadContent($contentId);
     $urlAliasNames = $this->nameSchemaResolver->resolveUrlAliasSchema($content);
     foreach ($urlAliasNames as $languageCode => $name) {
         try {
             $this->setMigrationTable();
             $this->urlAliasHandler->publishUrlAliasForLocation($locationId, $parentLocationId, $name, $languageCode, $content->contentInfo->alwaysAvailable);
             $this->setDefaultTable();
         } catch (Exception $e) {
             $this->setDefaultTable();
             throw $e;
         }
     }
     return count($urlAliasNames);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:27,代码来源:RegenerateUrlAliasesCommand.php

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

示例9: loadBlock

 /**
  * Loads Block object for the given $id.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If block could not be found.
  *
  * @param int|string $id
  *
  * @return \eZ\Publish\Core\FieldType\Page\Parts\Block
  */
 public function loadBlock($id)
 {
     if (isset($this->blocksById[$id])) {
         return $this->blocksById[$id];
     }
     $contentId = $this->getStorageGateway()->getContentIdByBlockId($id);
     $content = $this->contentService->loadContent($contentId);
     foreach ($content->getFields() as $field) {
         if (!$field->value instanceof Value) {
             continue;
         }
         foreach ($field->value->page->zones as $zone) {
             foreach ($zone->blocks as $block) {
                 if ($block->id === $id) {
                     return $this->blocksById[$id] = $block;
                 }
             }
         }
     }
     throw new NotFoundException('Block', $id);
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:30,代码来源:PageService.php

示例10: getLocationPathString

 /**
  * Returns location path string based on $contentId.
  *
  * @param int|mixed $contentId
  *
  * @return string
  */
 protected function getLocationPathString($contentId)
 {
     $content = $this->contentService->loadContent($contentId);
     $location = $this->locationService->loadLocation($content->contentInfo->mainLocationId);
     return $location->pathString;
 }
开发者ID:kamilmusial,项目名称:EzSystemsRecommendationBundle,代码行数:13,代码来源:RecommendationTwigExtension.php

示例11: loadContent

 /**
  * Loads content in a version of the given content object.
  *
  * If no version number is given, the method returns the current version
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  *
  * @param int $contentId
  * @param array $languages A language filter for fields. If not given all languages are returned
  * @param int $versionNo the version number. If not given the current version is returned.
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 public function loadContent($contentId, array $languages = null, $versionNo = null)
 {
     return $this->service->loadContent($contentId, $languages, $versionNo);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:18,代码来源:ContentService.php

示例12: loadContentByLocationId

 /**
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 protected function loadContentByLocationId($locationId)
 {
     return $this->contentService->loadContent($this->locationService->loadLocation($locationId)->contentId);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:7,代码来源:WebsiteToolbarController.php

示例13: loadContent

 /**
  * Loads content in a version of the given content object.
  *
  * If no version number is given, the method returns the current version
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the content or version with the given id and languages does not exist
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
  *
  * @param int $contentId
  * @param array $languages A language filter for fields. If not given all languages are returned
  * @param int $versionNo the version number. If not given the current version is returned
  * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Content
  */
 public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
 {
     return $this->service->loadContent($contentId, $languages, $versionNo, $useAlwaysAvailable);
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:19,代码来源:ContentService.php

示例14: getContentIdentifier

 /**
  * Returns ContentType identifier based on $contentId.
  *
  * @param int|mixed $contentId
  * @return string
  */
 private function getContentIdentifier($contentId)
 {
     $contentType = $this->contentTypeService->loadContentType($this->contentService->loadContent($contentId)->contentInfo->contentTypeId);
     return $contentType->identifier;
 }
开发者ID:sdaoudi,项目名称:EzSystemsRecommendationBundle,代码行数:11,代码来源:YooChooseNotifier.php

示例15: loadValueObject

 protected function loadValueObject($id)
 {
     return $this->contentService->loadContent($id);
 }
开发者ID:nlescure,项目名称:ezpublish-kernel,代码行数:4,代码来源:ContentParamConverter.php


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