public function EntityReferenceItem::getPropertyDefinitions

Implements ComplexDataInterface::getPropertyDefinitions().

Overrides ComplexDataInterface::getPropertyDefinitions

File

drupal/core/lib/Drupal/Core/Entity/Field/Type/EntityReferenceItem.php, line 33
Definition of Drupal\Core\Entity\Field\Type\EntityReferenceItem.

Class

EntityReferenceItem
Defines the 'entityreference_field' entity field item.

Namespace

Drupal\Core\Entity\Field\Type

Code

public function getPropertyDefinitions() {

  // Definitions vary by entity type, so key them by entity type.
  $entity_type = $this->definition['settings']['entity type'];
  if (!isset(self::$propertyDefinitions[$entity_type])) {
    self::$propertyDefinitions[$entity_type]['value'] = array(
      // @todo: Lookup the entity type's ID data type and use it here.
      'type' => 'integer',
      'label' => t('Entity ID'),
    );
    self::$propertyDefinitions[$entity_type]['entity'] = array(
      'type' => 'entity',
      'constraints' => array(
        'entity type' => $entity_type,
      ),
      'label' => t('Entity'),
      'description' => t('The referenced entity'),
      // The entity object is computed out of the entity id.
      'computed' => TRUE,
      'read-only' => FALSE,
      'settings' => array(
        'id source' => 'value',
      ),
    );
  }
  return self::$propertyDefinitions[$entity_type];
}