You are here

class EntityReferenceRevisionsItem in Entity Reference Revisions 8

Defines the 'entity_reference_revisions' entity field type.

Supported settings (below the definition's 'settings' key) are:

  • target_type: The entity type to reference. Required.
  • target_bundle: (optional): If set, restricts the entity bundles which may may be referenced. May be set to an single bundle, or to an array of allowed bundles.

Plugin annotation


@FieldType(
  id = "entity_reference_revisions",
  label = @Translation("Entity reference revisions"),
  description = @Translation("An entity field containing an entity reference to a specific revision."),
  category = @Translation("Reference revisions"),
  no_ui = FALSE,
  class = "\Drupal\entity_reference_revisions\Plugin\Field\FieldType\EntityReferenceRevisionsItem",
  list_class = "\Drupal\entity_reference_revisions\EntityReferenceRevisionsFieldItemList",
  default_formatter = "entity_reference_revisions_entity_view",
  default_widget = "entity_reference_revisions_autocomplete"
)

Hierarchy

Expanded class hierarchy of EntityReferenceRevisionsItem

2 files declare their use of EntityReferenceRevisionsItem
EntityReferenceRevisionItemNormalizer.php in src/Normalizer/EntityReferenceRevisionItemNormalizer.php
entity_reference_revisions.module in ./entity_reference_revisions.module
Provides a field that can reference other entities.

File

src/Plugin/Field/FieldType/EntityReferenceRevisionsItem.php, line 41

Namespace

Drupal\entity_reference_revisions\Plugin\Field\FieldType
View source
class EntityReferenceRevisionsItem extends EntityReferenceItem implements OptionsProviderInterface, PreconfiguredFieldUiOptionsInterface {

  /**
   * {@inheritdoc}
   */
  public function storageSettingsForm(array &$form, FormStateInterface $form_state, $has_data) {
    $entity_types = \Drupal::entityTypeManager()
      ->getDefinitions();
    $options = array();
    foreach ($entity_types as $entity_type) {
      if ($entity_type
        ->isRevisionable()) {
        $options[$entity_type
          ->id()] = $entity_type
          ->getLabel();
      }
    }
    $element['target_type'] = array(
      '#type' => 'select',
      '#title' => $this
        ->t('Type of item to reference'),
      '#options' => $options,
      '#default_value' => $this
        ->getSetting('target_type'),
      '#required' => TRUE,
      '#disabled' => $has_data,
      '#size' => 1,
    );
    return $element;
  }

  /**
   * {@inheritdoc}
   */
  public static function getPreconfiguredOptions() {
    $options = array();

    // Add all the commonly referenced entity types as distinct pre-configured
    // options.
    $entity_types = \Drupal::entityTypeManager()
      ->getDefinitions();
    $common_references = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
      return $entity_type
        ->get('common_reference_revisions_target') && $entity_type
        ->isRevisionable();
    });

    /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
    foreach ($common_references as $entity_type) {
      $options[$entity_type
        ->id()] = [
        'label' => $entity_type
          ->getLabel(),
        'field_storage_config' => [
          'settings' => [
            'target_type' => $entity_type
              ->id(),
          ],
        ],
      ];
      $default_reference_settings = $entity_type
        ->get('default_reference_revision_settings');
      if (is_array($default_reference_settings)) {
        $options[$entity_type
          ->id()] = array_merge($options[$entity_type
          ->id()], $default_reference_settings);
      }
    }
    return $options;
  }

  /**
   * {@inheritdoc}
   */
  public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $settings = $field_definition
      ->getSettings();
    $target_type_info = \Drupal::entityTypeManager()
      ->getDefinition($settings['target_type']);
    $properties = parent::propertyDefinitions($field_definition);
    if ($target_type_info
      ->getKey('revision')) {
      $target_revision_id_definition = DataReferenceTargetDefinition::create('integer')
        ->setLabel(t('@label revision ID', array(
        '@label' => $target_type_info
          ->getLabel(),
      )))
        ->setSetting('unsigned', TRUE);
      $target_revision_id_definition
        ->setRequired(TRUE);
      $properties['target_revision_id'] = $target_revision_id_definition;
    }
    $properties['entity'] = DataReferenceDefinition::create('entity_revision')
      ->setLabel($target_type_info
      ->getLabel())
      ->setDescription(t('The referenced entity revision'))
      ->setComputed(TRUE)
      ->setReadOnly(FALSE)
      ->setTargetDefinition(EntityDataDefinition::create($settings['target_type']));
    return $properties;
  }

  /**
   * {@inheritdoc}
   */
  public static function schema(FieldStorageDefinitionInterface $field_definition) {
    $target_type = $field_definition
      ->getSetting('target_type');
    $target_type_info = \Drupal::entityTypeManager()
      ->getDefinition($target_type);
    $schema = parent::schema($field_definition);
    if ($target_type_info
      ->getKey('revision')) {
      $schema['columns']['target_revision_id'] = array(
        'description' => 'The revision ID of the target entity.',
        'type' => 'int',
        'unsigned' => TRUE,
      );
      $schema['indexes']['target_revision_id'] = array(
        'target_revision_id',
      );
    }
    return $schema;
  }

  /**
   * {@inheritdoc}
   */
  public function setValue($values, $notify = TRUE) {
    if (isset($values) && !is_array($values)) {

      // If either a scalar or an object was passed as the value for the item,
      // assign it to the 'entity' property since that works for both cases.
      $this
        ->set('entity', $values, $notify);
    }
    else {
      parent::setValue($values, FALSE);

      // Support setting the field item with only one property, but make sure
      // values stay in sync if only property is passed.
      // NULL is a valid value, so we use array_key_exists().
      if (is_array($values) && array_key_exists('target_id', $values) && !isset($values['entity'])) {
        $this
          ->onChange('target_id', FALSE);
      }
      elseif (is_array($values) && array_key_exists('target_revision_id', $values) && !isset($values['entity'])) {
        $this
          ->onChange('target_revision_id', FALSE);
      }
      elseif (is_array($values) && !array_key_exists('target_id', $values) && !array_key_exists('target_revision_id', $values) && isset($values['entity'])) {
        $this
          ->onChange('entity', FALSE);
      }
      elseif (is_array($values) && array_key_exists('target_id', $values) && isset($values['entity'])) {

        // If both properties are passed, verify the passed values match. The
        // only exception we allow is when we have a new entity: in this case
        // its actual id and target_id will be different, due to the new entity
        // marker.
        $entity_id = $this
          ->get('entity')
          ->getTargetIdentifier();

        // If the entity has been saved and we're trying to set both the
        // target_id and the entity values with a non-null target ID, then the
        // value for target_id should match the ID of the entity value.
        if (!$this->entity
          ->isNew() && $values['target_id'] !== NULL && $entity_id != $values['target_id']) {
          throw new \InvalidArgumentException('The target id and entity passed to the entity reference item do not match.');
        }
      }

      // Notify the parent if necessary.
      if ($notify && $this
        ->getParent()) {
        $this
          ->getParent()
          ->onChange($this
          ->getName());
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public function getValue() {
    $values = parent::getValue();
    if ($this->entity instanceof EntityNeedsSaveInterface && $this->entity
      ->needsSave()) {
      $values['entity'] = $this->entity;
    }
    return $values;
  }

  /**
   * {@inheritdoc}
   */
  public function onChange($property_name, $notify = TRUE) {

    // Make sure that the target ID and the target property stay in sync.
    if ($property_name == 'entity') {
      $property = $this
        ->get('entity');
      $target_id = $property
        ->isTargetNew() ? NULL : $property
        ->getTargetIdentifier();
      $this
        ->writePropertyValue('target_id', $target_id);
      $this
        ->writePropertyValue('target_revision_id', $property
        ->getValue()
        ->getRevisionId());
    }
    elseif ($property_name == 'target_id' && $this->target_id != NULL && $this->target_revision_id) {
      $this
        ->writePropertyValue('entity', array(
        'target_id' => $this->target_id,
        'target_revision_id' => $this->target_revision_id,
      ));
    }
    elseif ($property_name == 'target_revision_id' && $this->target_revision_id && $this->target_id) {
      $this
        ->writePropertyValue('entity', array(
        'target_id' => $this->target_id,
        'target_revision_id' => $this->target_revision_id,
      ));
    }
    if ($notify && isset($this->parent)) {
      $this->parent
        ->onChange($this->name);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function isEmpty() {

    // Avoid loading the entity by first checking the 'target_id'.
    if ($this->target_id !== NULL && $this->target_revision_id !== NULL) {
      return FALSE;
    }
    if ($this->entity && $this->entity instanceof EntityInterface) {
      return FALSE;
    }
    return TRUE;
  }

  /**
   * {@inheritdoc}
   */
  public function preSave() {
    $has_new = $this
      ->hasNewEntity();

    // If it is a new entity, parent will save it.
    parent::preSave();
    $is_affected = TRUE;
    if (!$has_new) {

      // Create a new revision if it is a composite entity in a host with a new
      // revision.
      $host = $this
        ->getEntity();
      $needs_save = $this->entity instanceof EntityNeedsSaveInterface && $this->entity
        ->needsSave();

      // The item is considered to be affected if the field is either
      // untranslatable or there are translation changes. This ensures that for
      // translatable fields, a new revision of the referenced entity is only
      // created for the affected translations and that the revision ID does not
      // change on the unaffected translations. In turn, the host entity is not
      // marked as affected for these translations.
      $is_affected = !$this
        ->getFieldDefinition()
        ->isTranslatable() || $host instanceof TranslatableRevisionableInterface && $host
        ->hasTranslationChanges();
      if ($is_affected && !$host
        ->isNew() && $this->entity && $this->entity
        ->getEntityType()
        ->get('entity_revision_parent_id_field')) {
        if ($host
          ->isNewRevision()) {
          $this->entity
            ->setNewRevision();
          $needs_save = TRUE;
        }

        // Additionally ensure that the default revision state is kept in sync.
        if ($this->entity && $host
          ->isDefaultRevision() != $this->entity
          ->isDefaultRevision()) {
          $this->entity
            ->isDefaultRevision($host
            ->isDefaultRevision());
          $needs_save = TRUE;
        }
      }
      if ($needs_save) {

        // Because ContentEntityBase::hasTranslationChanges() does not check for
        // EntityReferenceRevisionsFieldItemList::hasAffectingChanges() on field
        // items that are not translatable, hidden on translation forms and not
        // in the default translation, this has to be handled here by setting
        // setRevisionTranslationAffected on host translations that holds a
        // reference that has been changed.
        if ($is_affected && $host instanceof TranslatableRevisionableInterface) {
          $languages = $host
            ->getTranslationLanguages();
          foreach ($languages as $langcode => $language) {
            $translation = $host
              ->getTranslation($langcode);
            if ($this->entity
              ->hasTranslation($langcode) && $this->entity
              ->getTranslation($langcode)
              ->hasTranslationChanges() && $this->target_revision_id != $this->entity
              ->getRevisionId()) {
              $translation
                ->setRevisionTranslationAffected(TRUE);
              $translation
                ->setRevisionTranslationAffectedEnforced(TRUE);
            }
          }
        }
        $this->entity
          ->save();
      }
    }
    if ($this->entity && $is_affected) {
      $this->target_revision_id = $this->entity
        ->getRevisionId();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function postSave($update) {
    parent::postSave($update);
    $needs_save = FALSE;

    // If any of entity, parent type or parent id is missing then return.
    if (!$this->entity || !$this->entity
      ->getEntityType()
      ->get('entity_revision_parent_type_field') || !$this->entity
      ->getEntityType()
      ->get('entity_revision_parent_id_field')) {
      return;
    }
    $entity = $this->entity;
    $parent_entity = $this
      ->getEntity();

    // If the entity has a parent field name get the key.
    if ($entity
      ->getEntityType()
      ->get('entity_revision_parent_field_name_field')) {
      $parent_field_name = $entity
        ->getEntityType()
        ->get('entity_revision_parent_field_name_field');

      // If parent field name has changed then set it.
      if ($entity
        ->get($parent_field_name)->value != $this
        ->getFieldDefinition()
        ->getName()) {
        $entity
          ->set($parent_field_name, $this
          ->getFieldDefinition()
          ->getName());
        $needs_save = TRUE;
      }
    }

    // Keep in sync the translation languages between the parent and the child.
    // For non translatable fields we have to do this in ::preSave but for
    // translatable fields we have all the information we need in ::delete.
    if (isset($parent_entity->original) && !$this
      ->getFieldDefinition()
      ->isTranslatable()) {
      $langcodes = array_keys($parent_entity
        ->getTranslationLanguages());
      $original_langcodes = array_keys($parent_entity->original
        ->getTranslationLanguages());
      if ($removed_langcodes = array_diff($original_langcodes, $langcodes)) {
        foreach ($removed_langcodes as $removed_langcode) {
          if ($entity
            ->hasTranslation($removed_langcode) && $entity
            ->getUntranslated()
            ->language()
            ->getId() != $removed_langcode) {
            $entity
              ->removeTranslation($removed_langcode);
          }
        }
        $needs_save = TRUE;
      }
    }
    $parent_type = $entity
      ->getEntityType()
      ->get('entity_revision_parent_type_field');
    $parent_id = $entity
      ->getEntityType()
      ->get('entity_revision_parent_id_field');

    // If the parent type has changed then set it.
    if ($entity
      ->get($parent_type)->value != $parent_entity
      ->getEntityTypeId()) {
      $entity
        ->set($parent_type, $parent_entity
        ->getEntityTypeId());
      $needs_save = TRUE;
    }

    // If the parent id has changed then set it.
    if ($entity
      ->get($parent_id)->value != $parent_entity
      ->id()) {
      $entity
        ->set($parent_id, $parent_entity
        ->id());
      $needs_save = TRUE;
    }
    if ($needs_save) {

      // Check if any of the keys has changed, save it, do not create a new
      // revision.
      $entity
        ->setNewRevision(FALSE);
      $entity
        ->save();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function deleteRevision() {
    $child = $this->entity;

    // Return early, and do not delete the child revision, when the child
    // revision is either:
    // 1: Missing.
    // 2: A default revision.
    if (!$child || $child
      ->isDefaultRevision()) {
      return;
    }
    $host = $this
      ->getEntity();
    $field_name = $this
      ->getFieldDefinition()
      ->getName() . '.target_revision_id';
    $all_revisions = \Drupal::entityQuery($host
      ->getEntityTypeId())
      ->condition($field_name, $child
      ->getRevisionId())
      ->allRevisions()
      ->accessCheck(FALSE)
      ->execute();
    if (count($all_revisions) > 1) {

      // Do not delete if there is more than one usage of this revision.
      return;
    }
    \Drupal::entityTypeManager()
      ->getStorage($child
      ->getEntityTypeId())
      ->deleteRevision($child
      ->getRevisionId());
  }

  /**
   * {@inheritdoc}
   */
  public function delete() {
    parent::delete();
    if ($this->entity && $this->entity
      ->getEntityType()
      ->get('entity_revision_parent_type_field') && $this->entity
      ->getEntityType()
      ->get('entity_revision_parent_id_field')) {

      // Only delete composite entities if the host field is not translatable.
      if (!$this
        ->getFieldDefinition()
        ->isTranslatable()) {
        \Drupal::queue('entity_reference_revisions_orphan_purger')
          ->createItem([
          'entity_id' => $this->entity
            ->id(),
          'entity_type_id' => $this->entity
            ->getEntityTypeId(),
        ]);
      }
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function onDependencyRemoval(FieldDefinitionInterface $field_definition, array $dependencies) {
    $changed = FALSE;
    $entity_type_manager = \Drupal::entityTypeManager();
    $target_entity_type = $entity_type_manager
      ->getDefinition($field_definition
      ->getFieldStorageDefinition()
      ->getSetting('target_type'));
    $handler_settings = $field_definition
      ->getSetting('handler_settings');

    // Update the 'target_bundles' handler setting if a bundle config dependency
    // has been removed.
    if (!empty($handler_settings['target_bundles'])) {
      if ($bundle_entity_type_id = $target_entity_type
        ->getBundleEntityType()) {
        if ($storage = $entity_type_manager
          ->getStorage($bundle_entity_type_id)) {
          foreach ($storage
            ->loadMultiple($handler_settings['target_bundles']) as $bundle) {
            if (isset($dependencies[$bundle
              ->getConfigDependencyKey()][$bundle
              ->getConfigDependencyName()])) {
              unset($handler_settings['target_bundles'][$bundle
                ->id()]);
              $changed = TRUE;

              // In case we deleted the only target bundle allowed by the field
              // we can log a message because the behaviour of the field will
              // have changed.
              if ($handler_settings['target_bundles'] === []) {
                \Drupal::logger('entity_reference_revisions')
                  ->notice('The %target_bundle bundle (entity type: %target_entity_type) was deleted. As a result, the %field_name entity reference revisions field (entity_type: %entity_type, bundle: %bundle) no longer specifies a specific target bundle. The field will now accept any bundle and may need to be adjusted.', [
                  '%target_bundle' => $bundle
                    ->label(),
                  '%target_entity_type' => $bundle
                    ->getEntityType()
                    ->getBundleOf(),
                  '%field_name' => $field_definition
                    ->getName(),
                  '%entity_type' => $field_definition
                    ->getTargetEntityTypeId(),
                  '%bundle' => $field_definition
                    ->getTargetBundle(),
                ]);
              }
            }
          }
        }
      }
    }
    if ($changed) {
      $field_definition
        ->setSetting('handler_settings', $handler_settings);
    }
    return $changed;
  }

  /**
   * {@inheritdoc}
   */
  public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
    $selection_manager = \Drupal::service('plugin.manager.entity_reference_selection');
    $entity_manager = \Drupal::entityTypeManager();

    // ERR field values are never cross referenced so we need to generate new
    // target entities. First, find the target entity type.
    $target_type_id = $field_definition
      ->getFieldStorageDefinition()
      ->getSetting('target_type');
    $target_type = $entity_manager
      ->getDefinition($target_type_id);
    $handler_settings = $field_definition
      ->getSetting('handler_settings');

    // Determine referenceable bundles.
    $bundle_manager = \Drupal::service('entity_type.bundle.info');
    if (isset($handler_settings['target_bundles']) && is_array($handler_settings['target_bundles'])) {
      if (empty($handler_settings['negate'])) {
        $bundles = $handler_settings['target_bundles'];
      }
      else {
        $bundles = array_filter($bundle_manager
          ->getBundleInfo($target_type_id), function ($bundle) use ($handler_settings) {
          return !in_array($bundle, $handler_settings['target_bundles'], TRUE);
        });
      }
    }
    else {
      $bundles = $bundle_manager
        ->getBundleInfo($target_type_id);
    }
    $bundle = array_rand($bundles);
    $label = NULL;
    if ($label_key = $target_type
      ->getKey('label')) {
      $random = new Random();

      // @TODO set the length somehow less arbitrary.
      $label = $random
        ->word(mt_rand(1, 10));
    }

    // Create entity stub.
    $entity = $selection_manager
      ->getSelectionHandler($field_definition)
      ->createNewEntity($target_type_id, $bundle, $label, 0);

    // Populate entity values and save.
    $instances = $entity_manager
      ->getStorage('field_config')
      ->loadByProperties([
      'entity_type' => $target_type_id,
      'bundle' => $bundle,
    ]);
    foreach ($instances as $instance) {
      $field_storage = $instance
        ->getFieldStorageDefinition();
      $max = $cardinality = $field_storage
        ->getCardinality();
      if ($cardinality == FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED) {

        // Just an arbitrary number for 'unlimited'
        $max = rand(1, 5);
      }
      $field_name = $field_storage
        ->getName();
      $entity->{$field_name}
        ->generateSampleItems($max);
    }
    $entity
      ->save();
    return [
      'target_id' => $entity
        ->id(),
      'target_revision_id' => $entity
        ->getRevisionId(),
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityReferenceItem::calculateDependencies public static function Calculates dependencies for field items. Overrides FieldItemBase::calculateDependencies
EntityReferenceItem::calculateStorageDependencies public static function Calculates dependencies for field items on the storage level. Overrides FieldItemBase::calculateStorageDependencies
EntityReferenceItem::defaultFieldSettings public static function Defines the field-level settings for this plugin. Overrides FieldItemBase::defaultFieldSettings 1
EntityReferenceItem::defaultStorageSettings public static function Defines the storage-level settings for this plugin. Overrides FieldItemBase::defaultStorageSettings 1
EntityReferenceItem::fieldSettingsAjaxProcess public static function Render API callback: Processes the field settings form and allows access to the form state.
EntityReferenceItem::fieldSettingsAjaxProcessElement public static function Adds entity_reference specific properties to AJAX form elements from the field settings form.
EntityReferenceItem::fieldSettingsForm public function Returns a form for the field-level settings. Overrides FieldItemBase::fieldSettingsForm 1
EntityReferenceItem::fieldSettingsFormValidate public static function Form element validation handler; Invokes selection plugin's validation.
EntityReferenceItem::formProcessMergeParent public static function Render API callback: Moves entity_reference specific Form API elements (i.e. 'handler_settings') up a level for easier processing by the validation and submission handlers.
EntityReferenceItem::getConstraints public function Gets a list of validation constraints. Overrides TypedData::getConstraints
EntityReferenceItem::getPossibleOptions public function Returns an array of possible values with labels for display. Overrides OptionsProviderInterface::getPossibleOptions
EntityReferenceItem::getPossibleValues public function Returns an array of possible values. Overrides OptionsProviderInterface::getPossibleValues
EntityReferenceItem::getRandomBundle protected static function Gets a bundle for a given entity type and selection options.
EntityReferenceItem::getSettableOptions public function Returns an array of settable values with labels for display. Overrides OptionsProviderInterface::getSettableOptions
EntityReferenceItem::getSettableValues public function Returns an array of settable values. Overrides OptionsProviderInterface::getSettableValues
EntityReferenceItem::hasNewEntity public function Determines whether the item holds an unsaved entity.
EntityReferenceItem::mainPropertyName public static function Returns the name of the main property, if any. Overrides FieldItemBase::mainPropertyName
EntityReferenceItem::settingsAjax public static function Ajax callback for the handler settings form.
EntityReferenceItem::settingsAjaxSubmit public static function Submit handler for the non-JS case.
EntityReferenceRevisionsItem::delete public function Defines custom delete behavior for field values. Overrides FieldItemBase::delete
EntityReferenceRevisionsItem::deleteRevision public function Defines custom revision delete behavior for field values. Overrides FieldItemBase::deleteRevision
EntityReferenceRevisionsItem::generateSampleValue public static function Generates placeholder field values. Overrides EntityReferenceItem::generateSampleValue
EntityReferenceRevisionsItem::getPreconfiguredOptions public static function Returns preconfigured field options for a field type. Overrides EntityReferenceItem::getPreconfiguredOptions
EntityReferenceRevisionsItem::getValue public function Gets the data value. Overrides EntityReferenceItem::getValue
EntityReferenceRevisionsItem::isEmpty public function Determines whether the data structure is empty. Overrides EntityReferenceItem::isEmpty
EntityReferenceRevisionsItem::onChange public function React to changes to a child property or item. Overrides EntityReferenceItem::onChange
EntityReferenceRevisionsItem::onDependencyRemoval public static function Informs the plugin that a dependency of the field will be deleted. Overrides EntityReferenceItem::onDependencyRemoval
EntityReferenceRevisionsItem::postSave public function Defines custom post-save behavior for field values. Overrides FieldItemBase::postSave
EntityReferenceRevisionsItem::preSave public function Defines custom presave behavior for field values. Overrides EntityReferenceItem::preSave
EntityReferenceRevisionsItem::propertyDefinitions public static function Defines field item properties. Overrides EntityReferenceItem::propertyDefinitions
EntityReferenceRevisionsItem::schema public static function Returns the schema for the field. Overrides EntityReferenceItem::schema
EntityReferenceRevisionsItem::setValue public function Sets the data value. Overrides EntityReferenceItem::setValue
EntityReferenceRevisionsItem::storageSettingsForm public function Returns a form for the storage-level settings. Overrides EntityReferenceItem::storageSettingsForm
FieldItemBase::fieldSettingsFromConfigData public static function Returns a settings array in the field type's canonical representation. Overrides FieldItemInterface::fieldSettingsFromConfigData 1
FieldItemBase::fieldSettingsToConfigData public static function Returns a settings array that can be stored as a configuration value. Overrides FieldItemInterface::fieldSettingsToConfigData 1
FieldItemBase::getEntity public function Gets the entity that field belongs to. Overrides FieldItemInterface::getEntity
FieldItemBase::getFieldDefinition public function Gets the field definition. Overrides FieldItemInterface::getFieldDefinition
FieldItemBase::getLangcode public function Gets the langcode of the field values held in the object. Overrides FieldItemInterface::getLangcode
FieldItemBase::getSetting protected function Returns the value of a field setting.
FieldItemBase::getSettings protected function Returns the array of field settings.
FieldItemBase::storageSettingsFromConfigData public static function Returns a settings array in the field type's canonical representation. Overrides FieldItemInterface::storageSettingsFromConfigData 2
FieldItemBase::storageSettingsToConfigData public static function Returns a settings array that can be stored as a configuration value. Overrides FieldItemInterface::storageSettingsToConfigData 2
FieldItemBase::view public function Returns a renderable array for a single field item. Overrides FieldItemInterface::view
FieldItemBase::writePropertyValue protected function Different to the parent Map class, we avoid creating property objects as far as possible in order to optimize performance. Thus we just update $this->values if no property object has been created yet. Overrides Map::writePropertyValue
FieldItemBase::__construct public function Constructs a TypedData object given its definition and context. Overrides TypedData::__construct 1
FieldItemBase::__get public function Magic method: Gets a property value. Overrides FieldItemInterface::__get 2
FieldItemBase::__isset public function Magic method: Determines whether a property is set. Overrides FieldItemInterface::__isset
FieldItemBase::__set public function Magic method: Sets a property value. Overrides FieldItemInterface::__set 1
FieldItemBase::__unset public function Magic method: Unsets a property. Overrides FieldItemInterface::__unset
Map::$definition protected property The data definition. Overrides TypedData::$definition
Map::$properties protected property The array of properties.
Map::$values protected property An array of values for the contained properties.
Map::applyDefaultValue public function Applies the default value. Overrides TypedData::applyDefaultValue 4
Map::get public function Gets a property object. Overrides ComplexDataInterface::get
Map::getIterator public function
Map::getProperties public function Gets an array of property objects. Overrides ComplexDataInterface::getProperties
Map::getString public function Returns a string representation of the data. Overrides TypedData::getString
Map::set public function Sets a property value. Overrides ComplexDataInterface::set
Map::toArray public function Returns an array of all property values. Overrides ComplexDataInterface::toArray 1
Map::__clone public function Magic method: Implements a deep clone.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TypedData::$name protected property The property name.
TypedData::$parent protected property The parent typed data object.
TypedData::createInstance public static function Constructs a TypedData object given its definition and context. Overrides TypedDataInterface::createInstance
TypedData::getDataDefinition public function Gets the data definition. Overrides TypedDataInterface::getDataDefinition
TypedData::getName public function Returns the name of a property or item. Overrides TypedDataInterface::getName
TypedData::getParent public function Returns the parent data structure; i.e. either complex data or a list. Overrides TypedDataInterface::getParent
TypedData::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
TypedData::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
TypedData::getPropertyPath public function Returns the property path of the data. Overrides TypedDataInterface::getPropertyPath
TypedData::getRoot public function Returns the root of the typed data tree. Overrides TypedDataInterface::getRoot
TypedData::setContext public function Sets the context of a property or item via a context aware parent. Overrides TypedDataInterface::setContext
TypedData::validate public function Validates the currently set data value. Overrides TypedDataInterface::validate
TypedDataTrait::$typedDataManager protected property The typed data manager used for creating the data types.
TypedDataTrait::getTypedDataManager public function Gets the typed data manager. 2
TypedDataTrait::setTypedDataManager public function Sets the typed data manager. 2