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
Пример #1
0
 /**
  * Gets name of a FieldDefinition description by loading ContentType based on Content/ContentInfo object.
  *
  * @param \eZ\Publish\API\Repository\Values\ValueObject $content Must be Content or ContentInfo object
  * @param string $fieldDefIdentifier Identifier for the field we want to get the name from
  * @param string $forcedLanguage Locale we want the content name translation in (e.g. "fre-FR"). Null by default (takes current locale)
  *
  * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentType When $content is not a valid Content object.
  *
  * @return string|null
  */
 public function getTranslatedFieldDefinitionDescription(ValueObject $content, $fieldDefIdentifier, $forcedLanguage = null)
 {
     if ($contentType = $this->getContentType($content)) {
         return $this->translationHelper->getTranslatedFieldDefinitionProperty($contentType, $fieldDefIdentifier, 'description', $forcedLanguage);
     }
     throw new InvalidArgumentType('$content', 'Content|ContentInfo', $content);
 }