You are here

public static function FieldCollection::propertyDefinitions in Field collection 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/FieldCollection.php \Drupal\field_collection\Plugin\Field\FieldType\FieldCollection::propertyDefinitions()

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides EntityReferenceItem::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/FieldCollection.php, line 83

Class

FieldCollection
Plugin implementation of the 'field_collection' field type.

Namespace

Drupal\field_collection\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['target_id'] = DataReferenceTargetDefinition::create('integer')
    ->setLabel(t('The ID of the field collection item.'))
    ->setSetting('unsigned', TRUE)
    ->setRequired(TRUE)
    ->setReadOnly(TRUE);
  $properties['revision_id'] = DataDefinition::create('integer')
    ->setLabel(t('Field collection item revision'))
    ->setReadOnly(TRUE);
  $properties['entity'] = DataReferenceDefinition::create('entity')
    ->setLabel(t('Field collection item'))
    ->setDescription(t('The referenced field collection item'))
    ->setComputed(TRUE)
    ->setReadOnly(TRUE)
    ->setTargetDefinition(EntityDataDefinition::create('field_collection_item'))
    ->addConstraint('EntityType', 'field_collection_item');
  return $properties;
}