function ShapeItem::schema

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php \Drupal\entity_test\Plugin\Field\FieldType\ShapeItem::schema()
  2. 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php \Drupal\entity_test\Plugin\Field\FieldType\ShapeItem::schema()
  3. 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php \Drupal\entity_test\Plugin\Field\FieldType\ShapeItem::schema()

Overrides FieldItemInterface::schema

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php, line 45

Class

ShapeItem
Defines the 'shape' field type.

Namespace

Drupal\entity_test\Plugin\Field\FieldType

Code

public static function schema(FieldStorageDefinitionInterface $field_definition) {
    $foreign_keys = [];
    // The 'foreign keys' key is not always used in tests.
    if ($field_definition->getSetting('foreign_key_name')) {
        $foreign_keys['foreign keys'] = [
            // This is a dummy foreign key definition, references a table that
            // doesn't exist, but that's not a problem.
$field_definition->getSetting('foreign_key_name') => [
                'table' => $field_definition->getSetting('foreign_key_name'),
                'columns' => [
                    $field_definition->getSetting('foreign_key_name') => 'id',
                ],
            ],
        ];
    }
    return [
        'columns' => [
            'shape' => [
                'type' => 'varchar',
                'length' => 32,
            ],
            'color' => [
                'type' => 'varchar',
                'length' => 32,
            ],
        ],
    ] + $foreign_keys;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.