本文整理汇总了PHP中eZ\Publish\API\Repository\ContentService::loadContentByContentInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentService::loadContentByContentInfo方法的具体用法?PHP ContentService::loadContentByContentInfo怎么用?PHP ContentService::loadContentByContentInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\ContentService
的用法示例。
在下文中一共展示了ContentService::loadContentByContentInfo方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: 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;
}
示例3: thereIsAUserContent
/**
* @Given /^there is a User Content$/
*/
public function thereIsAUserContent()
{
$login = 'user_content_' . microtime(true);
$email = $login . '@example.com';
$struct = $this->userService->newUserCreateStruct($login, $email, 'publish', 'eng-GB');
$struct->setField('first_name', 'John');
$struct->setField('last_name', 'Doe');
$parentGroup = $this->userService->loadUserGroup(11);
$user = $this->userService->createUser($struct, [$parentGroup]);
$this->currentContent = $this->contentService->loadContentByContentInfo($user->contentInfo);
}
示例4: getHandler
/**
* @param \eZ\Publish\API\Repository\Values\Content\Location $location
* @return \Heliopsis\eZFormsBundle\FormHandler\FormHandlerInterface
*/
private function getHandler(Location $location)
{
$handler = $this->formFacade->getHandler($location);
if ($handler instanceof LocationAwareHandlerInterface) {
$handler->setLocation($location);
}
if ($handler instanceof ContentAwareHandlerInterface) {
$handler->setContent($this->contentService->loadContentByContentInfo($location->contentInfo));
}
return $handler;
}
示例5: showBlogPostAction
/**
* Displays blog post content with random selected blog posts.
*
* @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view
*
* @return \eZ\Publish\Core\MVC\Symfony\View\ContentView
*/
public function showBlogPostAction(ContentView $view)
{
$languages = $this->configResolver->getParameter('languages');
$location = $this->locationService->loadLocation($view->getLocation()->parentLocationId);
$query = new Query();
$query->query = $this->childrenCriteria->generateChildCriterion($location, $languages);
$query->performCount = false;
$query->sortClauses = [new SortClause\DatePublished(Query::SORT_DESC)];
$results = $this->searchService->findContent($query);
$randomPosts = [];
foreach ($results->searchHits as $item) {
$randomPosts[] = $item->valueObject;
}
shuffle($randomPosts);
$view->addParameters(['location' => $location, 'content' => $this->contentService->loadContentByContentInfo($view->getLocation()->getContentInfo()), 'randomPosts' => array_slice($randomPosts, 0, $this->randomPostsLimit, true)]);
return $view;
}
示例6: loadContentByContentInfo
/**
* Loads content in a version for the given content info object.
*
* If no version number is given, the method returns the current version
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
* @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 loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null)
{
return $this->service->loadContentByContentInfo($contentInfo, $languages, $versionNo);
}
示例7: getFooter
/**
* Returns footer content object.
*
* @return \eZ\Publish\API\Repository\Values\Content\Content
*/
public function getFooter()
{
$location = $this->locationService->loadLocation($this->locationSettings['footer']);
return $this->contentService->loadContentByContentInfo($location->getContentInfo());
}
示例8: loadContentByContentInfo
/**
* Loads content in a version for the given content info object.
*
* If no version number is given, the method returns the current version
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
*
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
* @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 loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
{
return $this->service->loadContentByContentInfo($contentInfo, $languages, $versionNo, $useAlwaysAvailable);
}
示例9: showAction
/**
* Displays blog posts and gallery images on home page.
*
* @param \eZ\Publish\Core\MVC\Symfony\View\ContentView $view
*
* @return \eZ\Publish\Core\MVC\Symfony\View\ContentView
*/
public function showAction(ContentView $view)
{
$view->addParameters(['content' => $this->contentService->loadContentByContentInfo($view->getLocation()->getContentInfo()), 'blogPosts' => $this->fetchItems($this->blogLocationId, $this->blogPostLimit), 'galleryImages' => $this->fetchItems($this->galleryLocationId, $this->galleryImageLimit), 'galleryLocationId' => $this->galleryLocationId]);
return $view;
}
示例10: getCommentsConfig
/**
* @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
*
* @note Matched config is cached in memory by underlying matcher factory.
*
* @return array|null
*/
private function getCommentsConfig(ContentInfo $contentInfo)
{
$view = new ContentView(null, [], 'comments');
$view->setContent($this->contentService->loadContentByContentInfo($contentInfo));
return $this->matcherFactory->match($view);
}