LanguageReference.php

Same filename in other branches
  1. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/LanguageReference.php
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/LanguageReference.php
  3. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/LanguageReference.php

Namespace

Drupal\Core\TypedData\Plugin\DataType

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/LanguageReference.php

View source
<?php

namespace Drupal\Core\TypedData\Plugin\DataType;

use Drupal\Core\TypedData\DataReferenceBase;

/**
 * Defines the 'language_reference' data type.
 *
 * This serves as 'language' property of language field items and gets
 * its value set from the parent, i.e. LanguageItem.
 *
 * The plain value is the language object, i.e. an instance of
 * \Drupal\Core\Language\Language. For setting the value the language object or
 * the language code as string may be passed.
 *
 * @DataType(
 *   id = "language_reference",
 *   label = @Translation("Language reference"),
 *   definition_class = "\Drupal\Core\TypedData\DataReferenceDefinition"
 * )
 */
class LanguageReference extends DataReferenceBase {
    
    /**
     * {@inheritdoc}
     */
    public function getTargetIdentifier() {
        $language = $this->getTarget();
        return isset($language) ? $language->id() : NULL;
    }

}

Classes

Title Deprecated Summary
LanguageReference Defines the 'language_reference' data type.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.