interface FieldStorageDefinitionInterface
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php \Drupal\Core\Field\FieldStorageDefinitionInterface
- 10 core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php \Drupal\Core\Field\FieldStorageDefinitionInterface
- 11.x core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php \Drupal\Core\Field\FieldStorageDefinitionInterface
Defines an interface for entity field storage definitions.
Field storage definitions represent the part of full field definitions (see FieldDefinitionInterface) that is responsible for defining how the field is stored. While field definitions may differ by entity bundle, all of those bundle fields have to share the same common field storage definition. Thus, the storage definitions can be defined by entity type only. The bundle fields corresponding to a field storage definition may provide additional information; e.g., they may provide bundle-specific settings or constraints that are not present in the storage definition. However bundle fields may not override or alter any information provided by the storage definition except for the label and the description; e.g., any constraints and settings on the storage definition must be present on the bundle field as well.
Hierarchy
- interface \Drupal\Core\Cache\CacheableDependencyInterface
- interface \Drupal\Core\Field\FieldStorageDefinitionInterface extends \Drupal\Core\Cache\CacheableDependencyInterface
Expanded class hierarchy of FieldStorageDefinitionInterface
All classes that implement FieldStorageDefinitionInterface
See also
hook_entity_field_storage_info()
168 files declare their use of FieldStorageDefinitionInterface
- BaseFieldDefinitionTest.php in core/
tests/ Drupal/ Tests/ Core/ Entity/ BaseFieldDefinitionTest.php - BooleanItem.php in core/
lib/ Drupal/ Core/ Field/ Plugin/ Field/ FieldType/ BooleanItem.php - CommentItem.php in core/
modules/ comment/ src/ Plugin/ Field/ FieldType/ CommentItem.php - CommentStorageSchema.php in core/
modules/ comment/ src/ CommentStorageSchema.php - ConfigFieldDefinitionTest.php in core/
modules/ field/ tests/ src/ Kernel/ ConfigFieldDefinitionTest.php
File
-
core/
lib/ Drupal/ Core/ Field/ FieldStorageDefinitionInterface.php, line 26
Namespace
Drupal\Core\FieldView source
interface FieldStorageDefinitionInterface extends CacheableDependencyInterface {
/**
* Value indicating a field accepts an unlimited number of values.
*/
const CARDINALITY_UNLIMITED = -1;
/**
* Returns the machine name of the field.
*
* This defines how the field data is accessed from the entity. For example,
* if the field name is "foo", then $entity->foo returns its data.
*
* @return string
* The field name.
*/
public function getName();
/**
* Returns the field type.
*
* @return string
* The field type, i.e. the id of a field type plugin. For example 'text'.
*
* @see \Drupal\Core\Field\FieldTypePluginManagerInterface
*/
public function getType();
/**
* Returns the storage settings.
*
* Each field type defines the settings that are meaningful for that type.
* For example, a text field can define a 'max_length' setting, and an image
* field can define a 'alt_field_required' setting.
*
* The method always returns an array of all available settings for this field
* type, possibly with the default values merged in if values have not been
* provided for all available settings.
*
* @return mixed[]
* An array of key/value pairs.
*/
public function getSettings();
/**
* Returns the value of a given storage setting.
*
* @param string $setting_name
* The setting name.
*
* @return mixed
* The setting value.
*/
public function getSetting($setting_name);
/**
* Returns whether the field supports translation.
*
* @return bool
* TRUE if the field supports translation.
*/
public function isTranslatable();
/**
* Sets whether the field supports translation.
*
* @param bool $translatable
* Whether the field supports translation.
*
* @return $this
*/
public function setTranslatable($translatable);
/**
* Returns whether the field storage is revisionable.
*
* Note that if the entity type is revisionable and the field storage has a
* cardinality higher than 1, the field storage is considered revisionable
* by default.
*
* @return bool
* TRUE if the field is revisionable.
*/
public function isRevisionable();
/**
* Determines whether the field is queryable via QueryInterface.
*
* @return bool
* TRUE if the field is queryable.
*
* @deprecated in drupal:8.4.0 and is removed from drupal:9.0.0. Use
* \Drupal\Core\Field\FieldStorageDefinitionInterface::hasCustomStorage()
* instead.
*
* @see https://www.drupal.org/node/2856563
*/
public function isQueryable();
/**
* Returns the human-readable label for the field.
*
* @return string
* The field label.
*/
public function getLabel();
/**
* Returns the human-readable description for the field.
*
* This is displayed in addition to the label in places where additional
* descriptive information is helpful. For example, as help text below the
* form element in entity edit forms.
*
* @return string|null
* The field description, or NULL if no description is available.
*/
public function getDescription();
/**
* Gets an options provider for the given field item property.
*
* @param string $property_name
* The name of the property to get options for; e.g., 'value'.
* @param \Drupal\Core\Entity\FieldableEntityInterface $entity
* The entity for which the options should be provided.
*
* @return \Drupal\Core\TypedData\OptionsProviderInterface|null
* An options provider, or NULL if no options are defined.
*/
public function getOptionsProvider($property_name, FieldableEntityInterface $entity);
/**
* Returns whether the field can contain multiple items.
*
* @return bool
* TRUE if the field can contain multiple items, FALSE otherwise.
*/
public function isMultiple();
/**
* Returns the maximum number of items allowed for the field.
*
* Possible values are positive integers or
* FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED.
*
* @return int
* The field cardinality.
*/
public function getCardinality();
/**
* Gets the definition of a contained property.
*
* @param string $name
* The name of property.
*
* @return \Drupal\Core\TypedData\DataDefinitionInterface|null
* The definition of the property or NULL if the property does not exist.
*/
public function getPropertyDefinition($name);
/**
* Gets an array of property definitions of contained properties.
*
* @return \Drupal\Core\TypedData\DataDefinitionInterface[]
* An array of property definitions of contained properties, keyed by
* property name.
*/
public function getPropertyDefinitions();
/**
* Returns the names of the field's subproperties.
*
* A field is a list of items, and each item can contain one or more
* properties. All items for a given field contain the same property names,
* but the values can be different for each item.
*
* For example, an email field might just contain a single 'value' property,
* while a link field might contain 'title' and 'url' properties, and a text
* field might contain 'value', 'summary', and 'format' properties.
*
* @return string[]
* The property names.
*/
public function getPropertyNames();
/**
* Returns the name of the main property, if any.
*
* Some field items consist mainly of one main property, e.g. the value of a
* text field or the @code target_id @endcode of an entity reference. If the
* field item has no main property, the method returns NULL.
*
* @return string|null
* The name of the value property, or NULL if there is none.
*/
public function getMainPropertyName();
/**
* Returns the ID of the entity type the field is attached to.
*
* This method should not be confused with EntityInterface::getEntityTypeId()
* (configurable fields are config entities, and thus implement both
* interfaces):
* - FieldStorageDefinitionInterface::getTargetEntityTypeId() answers "as a
* field storage, which entity type are you attached to?".
* - EntityInterface::getEntityTypeId() answers "as a (config) entity, what
* is your own entity type?".
*
* @return string
* The entity type ID.
*/
public function getTargetEntityTypeId();
/**
* Returns the field schema.
*
* Note that this method returns an empty array for computed fields which have
* no schema.
*
* @return array[]
* The field schema, as an array of key/value pairs in the format returned
* by \Drupal\Core\Field\FieldItemInterface::schema():
* - columns: An array of Schema API column specifications, keyed by column
* name. This specifies what comprises a single value for a given field.
* No assumptions should be made on how storage backends internally use
* the original column name to structure their storage.
* - indexes: An array of Schema API index definitions. Some storage
* backends might not support indexes.
* - unique keys: An array of Schema API unique key definitions. Some
* storage backends might not support unique keys.
* - foreign keys: An array of Schema API foreign key definitions. Note,
* however, that depending on the storage backend specified for the field,
* the field data is not necessarily stored in SQL.
*/
public function getSchema();
/**
* Returns the field columns, as defined in the field schema.
*
* @return array[]
* The array of field columns, keyed by column name, in the same format
* returned by getSchema().
*
* @see \Drupal\Core\Field\FieldStorageDefinitionInterface::getSchema()
*/
public function getColumns();
/**
* Returns an array of validation constraints.
*
* See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
* details.
*
* @return array[]
* An array of validation constraint definitions, keyed by constraint name.
* Each constraint definition can be used for instantiating
* \Symfony\Component\Validator\Constraint objects.
*
* @see \Symfony\Component\Validator\Constraint
*/
public function getConstraints();
/**
* Returns a validation constraint.
*
* See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
* details.
*
* @param string $constraint_name
* The name of the constraint, i.e. its plugin id.
*
* @return array
* A validation constraint definition which can be used for instantiating a
* \Symfony\Component\Validator\Constraint object.
*
* @see \Symfony\Component\Validator\Constraint
*/
public function getConstraint($constraint_name);
/**
* Returns the name of the provider of this field.
*
* @return string
* The provider name; e.g., the module name.
*/
public function getProvider();
/**
* Returns the storage behavior for this field.
*
* Indicates whether the entity type's storage should take care of storing the
* field values or whether it is handled separately; e.g. by the
* module providing the field.
*
* @return bool
* FALSE if the storage takes care of storing the field, TRUE otherwise.
*/
public function hasCustomStorage();
/**
* Determines whether the field is a base field.
*
* Base fields are not specific to a given bundle or a set of bundles. This
* excludes configurable fields, as they are always attached to a specific
* bundle.
*
* @return bool
* Whether the field is a base field.
*/
public function isBaseField();
/**
* Returns a unique identifier for the field storage.
*
* @return string
*/
public function getUniqueStorageIdentifier();
/**
* Returns whether the field is deleted or not.
*
* @return bool
* TRUE if the field is deleted, FALSE otherwise.
*/
public function isDeleted();
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|---|
CacheableDependencyInterface::getCacheContexts | public | function | The cache contexts associated with this object. | 34 | |
CacheableDependencyInterface::getCacheMaxAge | public | function | The maximum age for which this object may be cached. | 34 | |
CacheableDependencyInterface::getCacheTags | public | function | The cache tags associated with this object. | 27 | |
FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED | constant | Value indicating a field accepts an unlimited number of values. | |||
FieldStorageDefinitionInterface::getCardinality | public | function | Returns the maximum number of items allowed for the field. | 2 | |
FieldStorageDefinitionInterface::getColumns | public | function | Returns the field columns, as defined in the field schema. | 2 | |
FieldStorageDefinitionInterface::getConstraint | public | function | Returns a validation constraint. | 1 | |
FieldStorageDefinitionInterface::getConstraints | public | function | Returns an array of validation constraints. | 1 | |
FieldStorageDefinitionInterface::getDescription | public | function | Returns the human-readable description for the field. | 1 | |
FieldStorageDefinitionInterface::getLabel | public | function | Returns the human-readable label for the field. | 1 | |
FieldStorageDefinitionInterface::getMainPropertyName | public | function | Returns the name of the main property, if any. | 2 | |
FieldStorageDefinitionInterface::getName | public | function | Returns the machine name of the field. | 1 | |
FieldStorageDefinitionInterface::getOptionsProvider | public | function | Gets an options provider for the given field item property. | 2 | |
FieldStorageDefinitionInterface::getPropertyDefinition | public | function | Gets the definition of a contained property. | 2 | |
FieldStorageDefinitionInterface::getPropertyDefinitions | public | function | Gets an array of property definitions of contained properties. | 2 | |
FieldStorageDefinitionInterface::getPropertyNames | public | function | Returns the names of the field's subproperties. | 2 | |
FieldStorageDefinitionInterface::getProvider | public | function | Returns the name of the provider of this field. | 2 | |
FieldStorageDefinitionInterface::getSchema | public | function | Returns the field schema. | 2 | |
FieldStorageDefinitionInterface::getSetting | public | function | Returns the value of a given storage setting. | 1 | |
FieldStorageDefinitionInterface::getSettings | public | function | Returns the storage settings. | 1 | |
FieldStorageDefinitionInterface::getTargetEntityTypeId | public | function | Returns the ID of the entity type the field is attached to. | 1 | |
FieldStorageDefinitionInterface::getType | public | function | Returns the field type. | 1 | |
FieldStorageDefinitionInterface::getUniqueStorageIdentifier | public | function | Returns a unique identifier for the field storage. | 2 | |
FieldStorageDefinitionInterface::hasCustomStorage | public | function | Returns the storage behavior for this field. | 2 | |
FieldStorageDefinitionInterface::isBaseField | public | function | Determines whether the field is a base field. | 2 | |
FieldStorageDefinitionInterface::isDeleted | public | function | Returns whether the field is deleted or not. | 2 | |
FieldStorageDefinitionInterface::isMultiple | public | function | Returns whether the field can contain multiple items. | 2 | |
FieldStorageDefinitionInterface::isQueryable | Deprecated | public | function | Determines whether the field is queryable via QueryInterface. | 2 |
FieldStorageDefinitionInterface::isRevisionable | public | function | Returns whether the field storage is revisionable. | 2 | |
FieldStorageDefinitionInterface::isTranslatable | public | function | Returns whether the field supports translation. | 1 | |
FieldStorageDefinitionInterface::setTranslatable | public | function | Sets whether the field supports translation. | 2 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.