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


PHP Repository\ContentService类代码示例

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


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

示例1: getTranslatedContentNameByContentInfo

 /**
  * Returns content name, translated, from a ContentInfo object.
  * By default this method uses prioritized languages, unless $forcedLanguage is provided.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  * @param string $forcedLanguage Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
  *
  * @todo Remove ContentService usage when translated names are available in ContentInfo (see https://jira.ez.no/browse/EZP-21755)
  *
  * @return string
  */
 public function getTranslatedContentNameByContentInfo(ContentInfo $contentInfo, $forcedLanguage = null)
 {
     if (isset($forcedLanguage) && $forcedLanguage === $contentInfo->mainLanguageCode) {
         return $contentInfo->name;
     }
     return $this->getTranslatedContentName($this->contentService->loadContentByContentInfo($contentInfo), $forcedLanguage);
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:18,代码来源:TranslationHelper.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->matcherFactoryMock = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Matcher\\MatcherFactoryInterface');
     $this->configResolverMock = $this->getMock('eZ\\Publish\\Core\\MVC\\ConfigResolverInterface');
     $this->contentServiceMock = $this->getMock('eZ\\Publish\\API\\Repository\\ContentService');
     $this->contentServiceMock->expects($this->any())->method('loadContentByContentInfo')->will($this->returnValue(new Content()));
 }
开发者ID:michalpipa,项目名称:CommentsBundle,代码行数:8,代码来源:CommentsRendererTest.php

示例3: getContentCreateStruct

 /**
  * Creates and prepares content create structure.
  *
  * @param array $data
  * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
  */
 private function getContentCreateStruct($data)
 {
     $contentType = $this->contentTypeService->loadContentTypeByIdentifier($data['content_type']);
     $struct = $this->contentService->newContentCreateStruct($contentType, '');
     $this->fillValueObject($struct, $data, ['content_type']);
     return $struct;
 }
开发者ID:silversolutions,项目名称:content-loader-bundle,代码行数:13,代码来源:Content.php

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

示例5: parse

 /**
  * Parse input structure
  *
  * @param array $data
  * @param \eZ\Publish\Core\REST\Common\Input\ParsingDispatcher $parsingDispatcher
  *
  * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
  */
 public function parse(array $data, ParsingDispatcher $parsingDispatcher)
 {
     $contentUpdateStruct = $this->contentService->newContentUpdateStruct();
     // Missing initial language code
     if (array_key_exists('initialLanguageCode', $data)) {
         $contentUpdateStruct->initialLanguageCode = $data['initialLanguageCode'];
     }
     // @todo Where to set the user?
     // @todo Where to set modification date?
     if (array_key_exists('fields', $data)) {
         if (!is_array($data['fields']) || !array_key_exists('field', $data['fields']) || !is_array($data['fields']['field'])) {
             throw new Exceptions\Parser("Invalid 'fields' element for VersionUpdate.");
         }
         $contentId = $this->requestParser->parseHref($data['__url'], 'contentId');
         foreach ($data['fields']['field'] as $fieldData) {
             if (!array_key_exists('fieldDefinitionIdentifier', $fieldData)) {
                 throw new Exceptions\Parser("Missing 'fieldDefinitionIdentifier' element in field data for VersionUpdate.");
             }
             if (!array_key_exists('fieldValue', $fieldData)) {
                 throw new Exceptions\Parser("Missing 'fieldValue' element for '{$fieldData['fieldDefinitionIdentifier']}' identifier in VersionUpdate.");
             }
             $fieldValue = $this->fieldTypeParser->parseFieldValue($contentId, $fieldData['fieldDefinitionIdentifier'], $fieldData['fieldValue']);
             $languageCode = null;
             if (array_key_exists('languageCode', $fieldData)) {
                 $languageCode = $fieldData['languageCode'];
             }
             $contentUpdateStruct->setField($fieldData['fieldDefinitionIdentifier'], $fieldValue, $languageCode);
         }
     }
     return $contentUpdateStruct;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:39,代码来源:VersionUpdate.php

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

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

示例8: handleAction

 public function handleAction(Request $request)
 {
     $user = $this->userService->loadUserByCredentials($request->username, $request->password);
     $this->repository->setCurrentUser($user);
     $contentCreateStruct = $this->contentProvider->newContentCreateStructFromRequest($request);
     $locationCreateStruct = $this->contentProvider->newLocationCreateStructFromRequest($request);
     $content = $this->contentService->createContent($contentCreateStruct, array($locationCreateStruct));
     $this->contentService->publishVersion($content->versionInfo);
 }
开发者ID:bdunogier,项目名称:eziftttbundle,代码行数:9,代码来源:Handler.php

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

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

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

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

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

示例14: displayGalleryAction

 /**
  * Displays the gallery.
  *
  * @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function displayGalleryAction(ContentView $view, Request $request)
 {
     $languages = $this->configResolver->getParameter('languages');
     $location = $view->getLocation();
     $query = new Query();
     $query->query = $this->childrenCriteria->generateChildCriterion($location, $languages);
     $pager = new Pagerfanta(new ContentSearchAdapter($query, $this->searchService));
     $pager->setMaxPerPage($this->galleryImagesLimit);
     $pager->setCurrentPage($request->get('page', 1));
     $view->addParameters(['location' => $location, 'content' => $this->contentService->loadContentByContentInfo($view->getLocation()->getContentInfo()), 'images' => $pager]);
     return $view;
 }
开发者ID:clash82,项目名称:ezplatform-demo,代码行数:20,代码来源:GalleryController.php

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


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