function EntityReferenceItem::schema
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema()
- 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema()
- 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php \Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem::schema()
Overrides FieldItemInterface::schema
1 call to EntityReferenceItem::schema()
- EntityViewsDataTest::setupFieldStorageDefinition in core/
modules/ views/ tests/ src/ Unit/ EntityViewsDataTest.php - Helper method to mock all store definitions.
1 method overrides EntityReferenceItem::schema()
- FileItem::schema in core/
modules/ file/ src/ Plugin/ Field/ FieldType/ FileItem.php - Returns the schema for the field.
File
-
core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ EntityReferenceItem.php, line 115
Class
- EntityReferenceItem
- Defines the 'entity_reference' entity field type.
Namespace
Drupal\Core\Field\Plugin\Field\FieldTypeCode
public static function schema(FieldStorageDefinitionInterface $field_definition) {
$target_type = $field_definition->getSetting('target_type');
$target_type_info = \Drupal::entityTypeManager()->getDefinition($target_type);
$properties = static::propertyDefinitions($field_definition)['target_id'];
if ($target_type_info->entityClassImplements(FieldableEntityInterface::class) && $properties->getDataType() === 'integer') {
$columns = [
'target_id' => [
'description' => 'The ID of the target entity.',
'type' => 'int',
'unsigned' => TRUE,
],
];
}
else {
$columns = [
'target_id' => [
'description' => 'The ID of the target entity.',
'type' => 'varchar_ascii',
// If the target entities act as bundles for another entity type,
// their IDs should not exceed the maximum length for bundles.
'length' => $target_type_info->getBundleOf() ? EntityTypeInterface::BUNDLE_MAX_LENGTH : 255,
],
];
}
$schema = [
'columns' => $columns,
'indexes' => [
'target_id' => [
'target_id',
],
],
];
return $schema;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.