PHP Класс eZ\Publish\Core\Helper\TranslationHelper

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$configResolver eZ\Publish\Core\MVC\ConfigResolverInterface
$contentService eZ\Publish\API\Repository\ContentService

Открытые методы

Метод Описание
__construct ( eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver, eZ\Publish\API\Repository\ContentService $contentService, array $siteAccessesByLanguage, Psr\Log\LoggerInterface $logger = null )
getAvailableLanguages ( ) : array Returns the list of all available languages, including the ones configured in related SiteAccesses.
getTranslatedByMethod ( eZ\Publish\API\Repository\Values\ValueObject $object, string $method, string $forcedLanguage = null ) : string | null Gets translated method generic helper.
getTranslatedByProperty ( eZ\Publish\API\Repository\Values\ValueObject $object, string $property, string $forcedLanguage = null ) : string | null Gets translated property generic helper.
getTranslatedContentName ( eZ\Publish\API\Repository\Values\Content\Content $content, string $forcedLanguage = null ) : string Returns content name, translated.
getTranslatedContentNameByContentInfo ( eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo, string $forcedLanguage = null ) : string Returns content name, translated, from a ContentInfo object.
getTranslatedField ( eZ\Publish\API\Repository\Values\Content\Content $content, string $fieldDefIdentifier, string $forcedLanguage = null ) : eZ\Publish\API\Repository\Values\Content\Field | null Returns Field object in the appropriate language for a given content.
getTranslatedFieldDefinitionProperty ( eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, string $fieldDefIdentifier, string $property = 'name', string $forcedLanguage = null ) : string | null Returns Field definition name in the appropriate language for a given content.
getTranslationSiteAccess ( string $languageCode ) : string | null Returns a SiteAccess name for translation in $languageCode.

Приватные методы

Метод Описание
getLanguages ( string | null $forcedLanguage = null, string | null $fallbackLanguage = null ) : array | mixed
getTranslatedContentNameByVersionInfo ( eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo, string $forcedLanguage = null ) : string Returns content name, translated, from a VersionInfo object.

Описание методов

__construct() публичный Метод

public __construct ( eZ\Publish\Core\MVC\ConfigResolverInterface $configResolver, eZ\Publish\API\Repository\ContentService $contentService, array $siteAccessesByLanguage, Psr\Log\LoggerInterface $logger = null )
$configResolver eZ\Publish\Core\MVC\ConfigResolverInterface
$contentService eZ\Publish\API\Repository\ContentService
$siteAccessesByLanguage array
$logger Psr\Log\LoggerInterface

getAvailableLanguages() публичный Метод

Returns the list of all available languages, including the ones configured in related SiteAccesses.
public getAvailableLanguages ( ) : array
Результат array

getTranslatedByMethod() публичный Метод

For generic use, expects method exposing translated property as-is on value object, typically $object->$method($language) Languages will consist of either forced language or current languages list, in addition helper will append null to list of languages so method may fallback to main/initial language if supported by domain.
public getTranslatedByMethod ( eZ\Publish\API\Repository\Values\ValueObject $object, string $method, string $forcedLanguage = null ) : string | null
$object eZ\Publish\API\Repository\Values\ValueObject Can be any kind of Value object which directly holds the methods that provides translated value.
$method string Method name, example 'getName', 'description'
$forcedLanguage string Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
Результат string | null

getTranslatedByProperty() публичный Метод

For generic use, expects array property as-is on value object, typically $object->$property[$language] Languages will consist of either forced language or current languages list, in addition helper will check if for mainLanguage property and append that to languages if alwaysAvailable property is true or non-existing.
public getTranslatedByProperty ( eZ\Publish\API\Repository\Values\ValueObject $object, string $property, string $forcedLanguage = null ) : string | null
$object eZ\Publish\API\Repository\Values\ValueObject Can be any kid of Value object which directly holds the translated property
$property string Property name, example 'names', 'descriptions'
$forcedLanguage string Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
Результат string | null

getTranslatedContentName() публичный Метод

By default this method uses prioritized languages, unless $forcedLanguage is provided.
public getTranslatedContentName ( eZ\Publish\API\Repository\Values\Content\Content $content, string $forcedLanguage = null ) : string
$content eZ\Publish\API\Repository\Values\Content\Content
$forcedLanguage string Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
Результат string

getTranslatedContentNameByContentInfo() публичный Метод

By default this method uses prioritized languages, unless $forcedLanguage is provided.
public getTranslatedContentNameByContentInfo ( eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo, string $forcedLanguage = null ) : string
$contentInfo eZ\Publish\API\Repository\Values\Content\ContentInfo
$forcedLanguage string Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
Результат string

getTranslatedField() публичный Метод

By default, this method will return the field in current language if translation is present. If not, main language will be used. If $forcedLanguage is provided, will return the field in this language, if translation is present.
public getTranslatedField ( eZ\Publish\API\Repository\Values\Content\Content $content, string $fieldDefIdentifier, string $forcedLanguage = null ) : eZ\Publish\API\Repository\Values\Content\Field | null
$content eZ\Publish\API\Repository\Values\Content\Content
$fieldDefIdentifier string Field definition identifier.
$forcedLanguage string Locale we want the field translation in (e.g. "fre-FR"). Null by default (takes current locale)
Результат eZ\Publish\API\Repository\Values\Content\Field | null

getTranslatedFieldDefinitionProperty() публичный Метод

By default, this method will return the field definition name in current language if translation is present. If not, main language will be used. If $forcedLanguage is provided, will return the field definition name in this language, if translation is present.
public getTranslatedFieldDefinitionProperty ( eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType, string $fieldDefIdentifier, string $property = 'name', string $forcedLanguage = null ) : string | null
$contentType eZ\Publish\API\Repository\Values\ContentType\ContentType
$fieldDefIdentifier string Field Definition identifier
$property string Specifies if 'name' or 'description' should be used
$forcedLanguage string Locale we want the field definition name translated in in (e.g. "fre-FR"). Null by default (takes current locale)
Результат string | null

getTranslationSiteAccess() публичный Метод

This is used for LanguageSwitcher feature (generate links for current content in a different language if available). Will use configured translation_siteaccesses if any. Otherwise will use related siteaccesses (e.g. same repository, same rootLocationId). Will return null if no translation SiteAccess can be found.
public getTranslationSiteAccess ( string $languageCode ) : string | null
$languageCode string Translation language code.
Результат string | null

Описание свойств

$configResolver защищенное свойство

protected ConfigResolverInterface,eZ\Publish\Core\MVC $configResolver
Результат eZ\Publish\Core\MVC\ConfigResolverInterface

$contentService защищенное свойство

protected ContentService,eZ\Publish\API\Repository $contentService
Результат eZ\Publish\API\Repository\ContentService