public function getTranslatedFieldDefinitionProperty(
        ContentType $contentType,
        $fieldDefIdentifier,
        $property = 'name',
        $forcedLanguage = null
    ) {
        $fieldDefinition = $contentType->getFieldDefinition($fieldDefIdentifier);
        if (!$fieldDefinition instanceof FieldDefinition) {
            throw new InvalidArgumentException(
                '$fieldDefIdentifier',
                "Field '{$fieldDefIdentifier}' not found on {$contentType->identifier}"
            );
        }

        $method = 'get' . $property;
        if (!method_exists($fieldDefinition, $method)) {
            throw new InvalidArgumentException('$property', "Method get'{$property}'() not found on FieldDefinition");
        }

        // Loop over prioritized languages to get the appropriate translated field definition name
        // Should ideally have used array_unique, but in that case the loop should ideally never reach last item
        foreach ($this->getLanguages($forcedLanguage, $contentType->mainLanguageCode) as $lang) {
            if ($name = $fieldDefinition->$method($lang)) {
                return $name;
            }
        }
    }
public function getTranslatedFieldDefinitionProperty(
        ContentType $contentType,
        $fieldDefIdentifier,
        $property = 'name',
        $forcedLanguage = null
    ) {
        $fieldDefinition = $contentType->getFieldDefinition($fieldDefIdentifier);
        if (!$fieldDefinition instanceof FieldDefinition) {
            throw new InvalidArgumentException(
                '$fieldDefIdentifier',
                "Field '{$fieldDefIdentifier}' not found on {$contentType->identifier}"
            );
        }

        $method = 'get' . $property;
        if (!method_exists($fieldDefinition, $method)) {
            throw new InvalidArgumentException('$property', "Method get'{$property}'() not found on FieldDefinition");
        }

        // Loop over prioritized languages to get the appropriate translated field definition name
        // Should ideally have used array_unique, but in that case the loop should ideally never reach last item
        foreach ($this->getLanguages($forcedLanguage, $contentType->mainLanguageCode) as $lang) {
            if ($name = $fieldDefinition->$method($lang)) {
                return $name;
            }
        }
    }
public function getTranslatedFieldDefinitionProperty ( ContentType $ contentType , $ fieldDefIdentifier , $ property = 'name' , $ forcedLanguage = null ) { $ fieldDefinition = $ contentType -> getFieldDefinition ( $ fieldDefIdentifier ) ; if ( ! $ fieldDefinition instanceof FieldDefinition ) { throw new InvalidArgumentException ( '$fieldDefIdentifier' , "Field '{$fieldDefIdentifier}' not found on {$contentType->identifier}" ) ; } $ method = 'get' . $ property ; if ( ! method_exists ( $ fieldDefinition , $ method ) ) { throw new InvalidArgumentException ( '$property' , "Method get'{$property}'() not found on FieldDefinition" ) ; } // Loop over prioritized languages to get the appropriate translated field definition name // Should ideally have used array_unique, but in that case the loop should ideally never reach last item foreach ( $ this -> getLanguages ( $ forcedLanguage , $ contentType -> mainLanguageCode ) as $ lang ) { if ( $ name = $ fieldDefinition -> $ method ( $ lang ) ) { return $ name ; } } }
Returns Field definition name in the appropriate language for a given content.

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.

@param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
@param string $fieldDefIdentifier Field Definition identifier
@param string $property Specifies if 'name' or 'description' should be used
@param string $forcedLanguage Locale we want the field definition name translated in in (e.g. "fre-FR"). Null by default (takes current locale)

@throws InvalidArgumentException

@return string|null
Returns Field definition name in the appropriate language for a given content .