public static function EntityReferenceHierarchy::propertyDefinitions in Entity Reference Hierarchy 8.2
Same name and namespace in other branches
- 3.x src/Plugin/Field/FieldType/EntityReferenceHierarchy.php \Drupal\entity_hierarchy\Plugin\Field\FieldType\EntityReferenceHierarchy::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/ EntityReferenceHierarchy.php, line 47
Class
- EntityReferenceHierarchy
- Plugin implementation of the 'entity_reference_hierarchy' field type.
Namespace
Drupal\entity_hierarchy\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties = parent::propertyDefinitions($field_definition);
$weight_definition = DataDefinition::create('integer')
->setLabel($field_definition
->getSetting('weight_label'));
$weight_definition
->addConstraint('Range', [
'min' => self::HIERARCHY_MIN_CHILD_WEIGHT,
]);
$weight_definition
->addConstraint('Range', [
'max' => self::HIERARCHY_MAX_CHILD_WEIGHT,
]);
$properties['weight'] = $weight_definition;
return $properties;
}