class ConfigurableEntityReferenceItem

Defines the 'entity_reference_configurable' entity field item.

Extends the Core 'entity_reference' entity field item with properties for revision ids, labels (for autocreate) and access.

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

  • target_type: The entity type to reference.

Hierarchy

Expanded class hierarchy of ConfigurableEntityReferenceItem

File

drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Type/ConfigurableEntityReferenceItem.php, line 21
Contains \Drupal\entity_reference\Type\ConfigurableEntityReferenceItem.

Namespace

Drupal\entity_reference\Type
View source
class ConfigurableEntityReferenceItem extends EntityReferenceItem {

  /**
   * Definitions of the contained properties.
   *
   * @see ConfigurableEntityReferenceItem::getPropertyDefinitions()
   *
   * @var array
   */
  static $propertyDefinitions;

  /**
   * Overrides \Drupal\Core\Entity\Field\Type\EntityReferenceItem::getPropertyDefinitions().
   */
  public function getPropertyDefinitions() {

    // Definitions vary by entity type, so key them by entity type.
    $target_type = $this->definition['settings']['target_type'];
    if (!isset(self::$propertyDefinitions[$target_type])) {

      // Call the parent to define the target_id and entity properties.
      parent::getPropertyDefinitions();
      static::$propertyDefinitions[$target_type]['revision_id'] = array(
        // @todo: Lookup the entity type's ID data type and use it here.
        'type' => 'integer',
        'label' => t('Revision ID'),
        'constraints' => array(
          'Range' => array(
            'min' => 0,
          ),
        ),
      );
      static::$propertyDefinitions[$target_type]['label'] = array(
        'type' => 'string',
        'label' => t('Label (auto-create)'),
        'computed' => TRUE,
      );
      static::$propertyDefinitions[$target_type]['access'] = array(
        'type' => 'boolean',
        'label' => t('Access'),
        'computed' => TRUE,
      );
    }
    return static::$propertyDefinitions[$target_type];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigurableEntityReferenceItem::$propertyDefinitions static property Definitions of the contained properties. Overrides EntityReferenceItem::$propertyDefinitions
ConfigurableEntityReferenceItem::getPropertyDefinitions public function Overrides \Drupal\Core\Entity\Field\Type\EntityReferenceItem::getPropertyDefinitions(). Overrides EntityReferenceItem::getPropertyDefinitions
EntityReferenceItem::get public function Overrides \Drupal\Core\Entity\Field\FieldItemBase::get(). Overrides Map::get
EntityReferenceItem::setValue public function Overrides \Drupal\Core\Entity\Field\FieldItemBase::get(). Overrides FieldItemBase::setValue
EntityReferenceItem::__get public function Overrides \Drupal\Core\Entity\Field\FieldItemBase::__get(). Overrides FieldItemBase::__get
EntityReferenceItem::__isset public function Implements \Drupal\Core\Entity\Field\FieldItemInterface::__isset(). Overrides FieldItemBase::__isset
FieldItemBase::getConstraints public function Implements \Drupal\Core\TypedData\TypedDataInterface::getConstraints(). Overrides TypedData::getConstraints
FieldItemBase::onChange public function Overrides \Drupal\Core\TypedData\Map::onChange(). Overrides Map::onChange
FieldItemBase::set public function Overrides \Drupal\Core\TypedData\Type\Map::set(). Overrides Map::set
FieldItemBase::__construct public function Overrides \Drupal\Core\TypedData\TypedData::__construct(). Overrides TypedData::__construct
FieldItemBase::__set public function Implements \Drupal\Core\Entity\Field\FieldItemInterface::__set(). Overrides FieldItemInterface::__set
FieldItemBase::__unset public function Implements \Drupal\Core\Entity\Field\FieldItemInterface::__unset(). Overrides FieldItemInterface::__unset
Map::$properties protected property The array of properties, each implementing the TypedDataInterface.
Map::$values protected property An array of values for the contained properties.
Map::getIterator public function Implements \IteratorAggregate::getIterator().
Map::getProperties public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getProperties(). Overrides ComplexDataInterface::getProperties
Map::getPropertyDefinition public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface::getPropertyDefinition
Map::getPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface::getPropertyValues
Map::getString public function Overrides \Drupal\Core\TypedData\TypedData::getString(). Overrides TypedData::getString
Map::getValue public function Overrides \Drupal\Core\TypedData\TypedData::getValue(). Overrides TypedData::getValue
Map::isEmpty public function Implements \Drupal\Core\TypedData\ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface::isEmpty 1
Map::setPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface::setPropertyValues
Map::__clone public function Magic method: Implements a deep clone.
TypedData::$definition protected property The data definition.
TypedData::$name protected property The property name.
TypedData::$parent protected property The parent typed data object.
TypedData::getDefinition public function Implements \Drupal\Core\TypedData\TypedDataInterface::getDefinition(). Overrides TypedDataInterface::getDefinition
TypedData::getName public function Implements \Drupal\Core\TypedData\TypedDataInterface::getName(). Overrides TypedDataInterface::getName
TypedData::getParent public function Implements \Drupal\Core\TypedData\TypedDataInterface::getParent(). Overrides TypedDataInterface::getParent
TypedData::getPropertyPath public function Implements \Drupal\Core\TypedData\TypedDataInterface::getPropertyPath(). Overrides TypedDataInterface::getPropertyPath
TypedData::getRoot public function Implements \Drupal\Core\TypedData\TypedDataInterface::getRoot(). Overrides TypedDataInterface::getRoot
TypedData::getType public function Implements \Drupal\Core\TypedData\TypedDataInterface::getType(). Overrides TypedDataInterface::getType
TypedData::setContext public function Implements \Drupal\Core\TypedData\TypedDataInterface::setContext(). Overrides TypedDataInterface::setContext 1
TypedData::validate public function Implements \Drupal\Core\TypedData\TypedDataInterface::validate(). Overrides TypedDataInterface::validate 3