本文整理汇总了PHP中eZ\Publish\API\Repository\Values\Content\Content::getVersionInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Content::getVersionInfo方法的具体用法?PHP Content::getVersionInfo怎么用?PHP Content::getVersionInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\API\Repository\Values\Content\Content
的用法示例。
在下文中一共展示了Content::getVersionInfo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslatedContentName
/**
* Returns content name, translated.
* By default this method uses prioritized languages, unless $forcedLanguage is provided.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $forcedLanguage Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
*
* @return string
*/
public function getTranslatedContentName(Content $content, $forcedLanguage = null)
{
foreach ($this->getLanguages($forcedLanguage) as $lang) {
$translatedName = $content->getVersionInfo()->getName($lang);
if ($translatedName !== null) {
return $translatedName;
}
}
}
示例2: getTranslatedContentName
/**
* Returns content name, translated.
* By default this method uses prioritized languages, unless $forcedLanguage is provided.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $forcedLanguage Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
*
* @return string
*/
public function getTranslatedContentName(Content $content, $forcedLanguage = null)
{
if ($forcedLanguage !== null) {
$languages = array($forcedLanguage);
} else {
$languages = $this->configResolver->getParameter('languages');
}
// Always add null to ensure we will pass it to VersionInfo::getName() if no valid translated name is found.
// So we have at least content name in main language.
$languages[] = null;
foreach ($languages as $lang) {
$translatedName = $content->getVersionInfo()->getName($lang);
if ($translatedName !== null) {
return $translatedName;
}
}
}
示例3: buildDomainUserGroupObject
/**
* Builds the domain UserGroup object from provided Content object
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
*
* @return \eZ\Publish\API\Repository\Values\User\UserGroup
*/
protected function buildDomainUserGroupObject(APIContent $content)
{
$locationService = $this->repository->getLocationService();
$subGroupCount = 0;
if ($content->getVersionInfo()->getContentInfo()->mainLocationId !== null) {
$mainLocation = $locationService->loadLocation($content->getVersionInfo()->getContentInfo()->mainLocationId);
$parentLocation = $locationService->loadLocation($mainLocation->parentLocationId);
$subGroups = $this->searchSubGroups($mainLocation->id, null, Location::SORT_ORDER_ASC, 0, 0);
$subGroupCount = $subGroups->totalCount;
}
return new UserGroup(array('content' => $content, 'parentId' => isset($parentLocation) ? $parentLocation->contentId : null, 'subGroupCount' => $subGroupCount));
}
示例4: getVersionInfo
/**
* Returns the VersionInfo for this version
*
* @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
*/
public function getVersionInfo()
{
return $this->content->getVersionInfo();
}
示例5: assertContentValues
/**
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param array $languages
* @param bool $draft
*/
protected function assertContentValues(APIContent $content, array $languages = null, $draft = false)
{
$versionInfoValues = $this->getVersionInfoExpectedValues($draft);
$contentInfoValues = $this->getContentInfoExpectedValues();
$fieldValuesValues = $this->getFieldValuesExpectedValues($languages);
$this->assertPropertiesCorrect($versionInfoValues, $content->getVersionInfo());
$this->assertPropertiesCorrect($contentInfoValues, $content->contentInfo);
$this->assertEquals($fieldValuesValues, $content->fields);
// @todo assert relations
$this->assertEquals($content->id, $content->contentInfo->id);
}
示例6: 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
*/
protected function getFieldTypeIdentifier(Content $content, Field $field)
{
$contentInfo = $content->getVersionInfo()->getContentInfo();
$key = $contentInfo->contentTypeId . ' ' . $field->fieldDefIdentifier;
if (!isset($this->fieldTypeIdentifiers[$key])) {
$contentType = $this->repository->getContentTypeService()->loadContentType($contentInfo->contentTypeId);
$this->fieldTypeIdentifiers[$key] = $contentType->getFieldDefinition($field->fieldDefIdentifier)->fieldTypeIdentifier;
}
return $this->fieldTypeIdentifiers[$key];
}
示例7: testUpdateContentMetadataNotUpdatesContentVersion
/**
* Test for the updateContentMetadata() method.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
*
* @return void
* @see \eZ\Publish\API\Repository\ContentService::updateContentMetadata()
* @depends eZ\Publish\API\Repository\Tests\ContentServiceTest::testUpdateContentMetadata
*/
public function testUpdateContentMetadataNotUpdatesContentVersion($content)
{
$this->assertEquals(1, $content->getVersionInfo()->versionNo);
}
示例8: getTranslatedContentName
/**
* Returns content name, translated.
* By default this method uses prioritized languages, unless $forcedLanguage is provided.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $forcedLanguage Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
*
* @return string
*/
public function getTranslatedContentName(Content $content, $forcedLanguage = null)
{
return $this->getTranslatedContentNameByVersionInfo($content->getVersionInfo(), $forcedLanguage);
}
示例9: renderContent
/**
* Renders $content by selecting the right template.
* $content will be injected in the selected template.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string $viewType Variation of display for your content. Default is 'full'.
* @param array $parameters Parameters to pass to the template called to
* render the view. By default, it's empty. 'content' entry is
* reserved for the Content that is rendered.
* @throws \RuntimeException
*
* @return string
*/
public function renderContent(Content $content, $viewType = ViewManagerInterface::VIEW_TYPE_FULL, $parameters = array())
{
$contentInfo = $content->getVersionInfo()->getContentInfo();
foreach ($this->getAllContentViewProviders() as $viewProvider) {
$view = $viewProvider->getView($contentInfo, $viewType);
if ($view instanceof ContentViewInterface) {
$parameters['content'] = $content;
return $this->renderContentView($view, $parameters);
}
}
throw new RuntimeException("Unable to find a template for #{$contentInfo->id}");
}
示例10: renderPreview
/**
* Returns preview for $content (versionNo to display is held in $content->versionInfo).
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param array $params Hash of arbitrary parameters to pass to final view
* @param \eZ\Publish\Core\MVC\Legacy\Templating\LegacyHelper $legacyHelper
*
* @return string
*/
public function renderPreview(APIContent $content, array $params, LegacyHelper $legacyHelper)
{
/** @var \eZ\Publish\Core\MVC\Symfony\SiteAccess $siteAccess */
$siteAccess = $this->getCurrentRequest()->attributes->get('siteaccess');
$moduleResult = array();
// Filling up moduleResult
$result = $this->getLegacyKernel()->runCallback(function () use($content, $params, $siteAccess, &$moduleResult) {
$contentViewModule = eZModule::findModule('content');
$moduleResult = $contentViewModule->run('versionview', array($content->contentInfo->id, $content->getVersionInfo()->versionNo, $content->getVersionInfo()->languageCodes[0]), false, array('site_access' => $siteAccess->name) + $params);
return ezpEvent::getInstance()->filter('response/output', $moduleResult['content']);
}, false);
$legacyHelper->loadDataFromModuleResult($moduleResult);
return $result;
}
示例11: copyContentObject
/**
* Copies a content object.
*
* @param \eZ\Publish\API\Repository\Values\Content\Content $content
* @param string[] $overwrites
*
* @return Values\Content\ContentStub
*/
private function copyContentObject(Content $content, array $overwrites = array())
{
$names = array('id', 'fields', 'contentTypeId', 'versionNo', 'repository');
$values = array();
foreach ($names as $name) {
if (array_key_exists($name, $overwrites)) {
$values[$name] = $overwrites[$name];
} else {
$values[$name] = $content->{$name};
}
}
$newContent = new ContentStub($values);
// copy relations
$relations = $this->loadRelations($content->getVersionInfo());
foreach ($relations as $relation) {
$this->addRelation($newContent->getVersionInfo(), $relation->getDestinationContentInfo());
}
return $newContent;
}