public function EntityReferenceItem::getPropertyDefinitions

Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions().

Overrides Map::getPropertyDefinitions

1 call to EntityReferenceItem::getPropertyDefinitions()
1 method overrides EntityReferenceItem::getPropertyDefinitions()

File

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

Class

EntityReferenceItem
Defines the 'entity_reference' entity field item.

Namespace

Drupal\Core\Entity\Field\Type

Code

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])) {
    static::$propertyDefinitions[$target_type]['target_id'] = array(
      // @todo: Lookup the entity type's ID data type and use it here.
      'type' => 'integer',
      'label' => t('Entity ID'),
      'constraints' => array(
        'Range' => array(
          'min' => 0,
        ),
      ),
    );
    static::$propertyDefinitions[$target_type]['entity'] = array(
      'type' => 'entity',
      'constraints' => array(
        'EntityType' => $target_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' => 'target_id',
      ),
    );
  }
  return static::$propertyDefinitions[$target_type];
}