interface FieldConfigInterface in Zircon Profile 8
Same name in this branch
- 8 core/modules/field/src/FieldConfigInterface.php \Drupal\field\FieldConfigInterface
- 8 core/lib/Drupal/Core/Field/FieldConfigInterface.php \Drupal\Core\Field\FieldConfigInterface
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Field/FieldConfigInterface.php \Drupal\Core\Field\FieldConfigInterface
Defines an interface for configurable field definitions.
This interface allows both configurable fields and overridden base fields to share a common interface. The interface also extends ConfigEntityInterface to ensure that implementations have the expected save() method.
Hierarchy
- interface \Drupal\Core\Field\FieldDefinitionInterface; interface \Drupal\Core\Config\Entity\ConfigEntityInterface
- interface \Drupal\Core\Field\FieldConfigInterface
Expanded class hierarchy of FieldConfigInterface
All classes that implement FieldConfigInterface
See also
\Drupal\Core\Field\Entity\BaseFieldOverride
\Drupal\field\Entity\FieldConfig
2 files declare their use of FieldConfigInterface
- MigrateCommentFieldInstanceTest.php in core/
modules/ comment/ src/ Tests/ Migrate/ d7/ MigrateCommentFieldInstanceTest.php - Contains \Drupal\comment\Tests\Migrate\d7\MigrateCommentFieldInstanceTest.
- MigrateUserPictureFieldInstanceTest.php in core/
modules/ user/ src/ Tests/ Migrate/ MigrateUserPictureFieldInstanceTest.php - Contains \Drupal\user\Tests\Migrate\MigrateUserPictureFieldInstanceTest.
File
- core/
lib/ Drupal/ Core/ Field/ FieldConfigInterface.php, line 22 - Contains \Drupal\Core\Field\FieldConfigInterface.
Namespace
Drupal\Core\FieldView source
interface FieldConfigInterface extends FieldDefinitionInterface, ConfigEntityInterface {
/**
* Sets the field definition label.
*
* @param string $label
* The label to set.
*
* @return $this
*/
public function setLabel($label);
/**
* Sets a human readable description.
*
* Descriptions are usually used on user interfaces where the data is edited
* or displayed.
*
* @param string $description
* The description for this field.
*
* @return $this
*/
public function setDescription($description);
/**
* Sets whether the field is translatable.
*
* @param bool $translatable
* Whether the field is translatable.
*
* @return $this
*/
public function setTranslatable($translatable);
/**
* Sets field settings.
*
* Note that the method does not unset existing settings not specified in the
* incoming $settings array.
*
* For example:
* @code
* // Given these are the default settings.
* $field_definition->getSettings() === [
* 'fruit' => 'apple',
* 'season' => 'summer',
* ];
* // Change only the 'fruit' setting.
* $field_definition->setSettings(['fruit' => 'banana']);
* // The 'season' setting persists unchanged.
* $field_definition->getSettings() === [
* 'fruit' => 'banana',
* 'season' => 'summer',
* ];
* @endcode
*
* For clarity, it is preferred to use setSetting() if not all available
* settings are supplied.
*
* @param array $settings
* The array of field settings.
*
* @return $this
*/
public function setSettings(array $settings);
/**
* Sets the value for a field setting by name.
*
* @param string $setting_name
* The name of the setting.
* @param mixed $value
* The value of the setting.
*
* @return $this
*/
public function setSetting($setting_name, $value);
/**
* Sets whether the field can be empty.
*
* If a field is required, an entity needs to have at least a valid,
* non-empty item in that field's FieldItemList in order to pass validation.
*
* An item is considered empty if its isEmpty() method returns TRUE.
* Typically, that is if at least one of its required properties is empty.
*
* @param bool $required
* TRUE if the field is required. FALSE otherwise.
*
* @return $this
* The current object, for a fluent interface.
*/
public function setRequired($required);
/**
* Sets a default value.
*
* Note that if a default value callback is set, it will take precedence over
* any value set here.
*
* @param mixed $value
* The default value for the field. This can be either:
* - a literal, in which case it will be assigned to the first property of
* the first item.
* - a numerically indexed array of items, each item being a property/value
* array.
* - a non-numerically indexed array, in which case the array is assumed to
* be a property/value array and used as the first item
* - NULL or array() for no default value.
*
* @return $this
*/
public function setDefaultValue($value);
/**
* Sets a custom default value callback.
*
* If set, the callback overrides any set default value.
*
* @param string|null $callback
* The callback to invoke for getting the default value (pass NULL to unset
* a previously set callback). The callback will be invoked with the
* following arguments:
* - \Drupal\Core\Entity\FieldableEntityInterface $entity
* The entity being created.
* - \Drupal\Core\Field\FieldDefinitionInterface $definition
* The field definition.
* It should return the default value in the format accepted by the
* setDefaultValue() method.
*
* @return $this
*/
public function setDefaultValueCallback($callback);
/**
* Sets constraints for a given field item property.
*
* Note: this overwrites any existing property constraints. If you need to
* add to the existing constraints, use
* \Drupal\Core\Field\FieldConfigInterface::addPropertyConstraints()
*
* Note that constraints added via this method are not stored in configuration
* and as such need to be added at runtime using
* hook_entity_bundle_field_info_alter().
*
* @param string $name
* The name of the property to set constraints for.
* @param array $constraints
* The constraints to set.
*
* @return static
* The object itself for chaining.
*
* @see hook_entity_bundle_field_info_alter()
*/
public function setPropertyConstraints($name, array $constraints);
/**
* Adds constraints for a given field item property.
*
* Adds a constraint to a property of a field item. e.g.
* @code
* // Limit the field item's value property to the range 0 through 10.
* // e.g. $node->field_how_many->value.
* $field->addPropertyConstraints('value', [
* 'Range' => [
* 'min' => 0,
* 'max' => 10,
* ]
* ]);
* @endcode
*
* If you want to add a validation constraint that applies to the
* \Drupal\Core\Field\FieldItemList, use FieldConfigInterface::addConstraint()
* instead.
*
* Note: passing a new set of options for an existing property constraint will
* overwrite with the new options.
*
* Note that constraints added via this method are not stored in configuration
* and as such need to be added at runtime using
* hook_entity_bundle_field_info_alter().
*
* @param string $name
* The name of the property to set constraints for.
* @param array $constraints
* The constraints to set.
*
* @return static
* The object itself for chaining.
*
* @see \Drupal\Core\Field\FieldConfigInterface::addConstraint()
* @see hook_entity_bundle_field_info_alter()
*/
public function addPropertyConstraints($name, array $constraints);
/**
* Adds a validation constraint to the FieldItemList.
*
* Note: If you wish to apply a constraint to just a property of a FieldItem
* use \Drupal\Core\Field\FieldConfigInterface::addPropertyConstraints()
* instead.
* @code
* // Add a constraint to the 'field_username' FieldItemList.
* // e.g. $node->field_username
* $fields['field_username']->addConstraint('UniqueField');
* @endcode
*
* If you wish to apply a constraint to a \Drupal\Core\Field\FieldItem instead
* of a property or FieldItemList, you can use the
* \Drupal\Core\Field\FieldConfigBase::getItemDefinition() method.
* @code
* // Add a constraint to the 'field_entity_reference' FieldItem (entity
* // reference item).
* $fields['field_entity_reference']->getItemDefinition()->addConstraint('MyCustomFieldItemValidationPlugin', []);
* @endcode
*
* See \Drupal\Core\TypedData\DataDefinitionInterface::getConstraints() for
* details.
*
* Note that constraints added via this method are not stored in configuration
* and as such need to be added at runtime using
* hook_entity_bundle_field_info_alter().
*
* @param string $constraint_name
* The name of the constraint to add, i.e. its plugin id.
* @param array|null $options
* The constraint options as required by the constraint plugin, or NULL.
*
* @return static
* The object itself for chaining.
*
* @see \Drupal\Core\Field\FieldItemList
* @see \Drupal\Core\Field\FieldConfigInterface::addPropertyConstraints()
* @see hook_entity_bundle_field_info_alter()
*/
public function addConstraint($constraint_name, $options = NULL);
/**
* Sets the array of validation constraints for the FieldItemList.
*
* NOTE: This will overwrite any previously set constraints. In most cases
* FieldConfigInterface::addConstraint() should be used instead.
*
* Note that constraints added via this method are not stored in configuration
* and as such need to be added at runtime using
* hook_entity_bundle_field_info_alter().
*
* @param array $constraints
* The array of constraints. See
* \Drupal\Core\TypedData\TypedDataManager::getConstraints() for details.
*
* @return $this
*
* @see \Drupal\Core\TypedData\DataDefinition::addConstraint()
* @see \Drupal\Core\TypedData\DataDefinition::getConstraints()
* @see \Drupal\Core\Field\FieldItemList
* @see hook_entity_bundle_field_info_alter()
*/
public function setConstraints(array $constraints);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessibleInterface:: |
public | function | Checks data value access. | 5 |
CacheableDependencyInterface:: |
public | function | The cache contexts associated with this object. | 26 |
CacheableDependencyInterface:: |
public | function | The maximum age for which this object may be cached. | 26 |
CacheableDependencyInterface:: |
public | function | The cache tags associated with this object. | 19 |
ConfigEntityInterface:: |
public | function | Calculates dependencies and stores them in the dependency property. | 2 |
ConfigEntityInterface:: |
public | function | Disables the configuration entity. | 2 |
ConfigEntityInterface:: |
public | function | Enables the configuration entity. | 2 |
ConfigEntityInterface:: |
public | function | Returns the value of a property. | 2 |
ConfigEntityInterface:: |
public | function | Gets the configuration dependencies. | 2 |
ConfigEntityInterface:: |
public | function | Gets whether on not the data is trusted. | 2 |
ConfigEntityInterface:: |
public | function | Checks whether this entity is installable. | 2 |
ConfigEntityInterface:: |
public | function | Returns whether this entity is being changed as part of an import process. | 2 |
ConfigEntityInterface:: |
public | function | Returns whether this entity is being changed during the uninstall process. | 2 |
ConfigEntityInterface:: |
public | function | Informs the entity that entities it depends on will be deleted. | 2 |
ConfigEntityInterface:: |
public | function | Sets the value of a property. | 2 |
ConfigEntityInterface:: |
public | function | Sets the status of the configuration entity. | 3 |
ConfigEntityInterface:: |
public | function | Sets the status of the isSyncing flag. | 2 |
ConfigEntityInterface:: |
public | function | Returns whether the configuration entity is enabled. | 2 |
ConfigEntityInterface:: |
public | function | Sets that the data should be trusted. | 2 |
DataDefinitionInterface:: |
public static | function | Creates a new data definition object. | 2 |
DataDefinitionInterface:: |
public | function | Returns the class used for creating the typed data object. | 2 |
DataDefinitionInterface:: |
public | function | Returns a validation constraint. | 2 |
DataDefinitionInterface:: |
public | function | Returns an array of validation constraints. | 2 |
DataDefinitionInterface:: |
public | function | Returns the data type of the data. | 2 |
DataDefinitionInterface:: |
public | function | Returns a human readable description. | 2 |
DataDefinitionInterface:: |
public | function | Returns a human readable label. | 2 |
DataDefinitionInterface:: |
public | function | Returns the value of a given setting. | 2 |
DataDefinitionInterface:: |
public | function | Returns the array of settings, as required by the used class. | 2 |
DataDefinitionInterface:: |
public | function | Determines whether the data value is computed. | 3 |
DataDefinitionInterface:: |
public | function | Returns whether the data is multi-valued, i.e. a list of data items. | 2 |
DataDefinitionInterface:: |
public | function | Determines whether the data is read-only. | 3 |
EntityInterface:: |
public | function | Gets the bundle of the entity. | 2 |
EntityInterface:: |
public static | function | Constructs a new entity object, without permanently saving it. | 2 |
EntityInterface:: |
public | function | Creates a duplicate of the entity. | 2 |
EntityInterface:: |
public | function | Deletes an entity permanently. | 2 |
EntityInterface:: |
public | function | Enforces an entity to be new. | 2 |
EntityInterface:: |
public | function | Returns the cache tags that should be used to invalidate caches. | 2 |
EntityInterface:: |
public | function | Gets the key that is used to store configuration dependencies. | 2 |
EntityInterface:: |
public | function | Gets the configuration dependency name. | 2 |
EntityInterface:: |
public | function | Gets the configuration target identifier for the entity. | 2 |
EntityInterface:: |
public | function | Gets the entity type definition. | 2 |
EntityInterface:: |
public | function | Gets the ID of the type of the entity. | 2 |
EntityInterface:: |
public | function | Gets the original ID. | 2 |
EntityInterface:: |
public | function | Gets a typed data object for this entity object. | 2 |
EntityInterface:: |
public | function | Indicates if a link template exists for a given key. | 2 |
EntityInterface:: |
public | function | Gets the identifier. | 2 |
EntityInterface:: |
public | function | Determines whether the entity is new. | 2 |
EntityInterface:: |
public | function | Gets the label of the entity. | 2 |
EntityInterface:: |
public | function | Gets the language of the entity. | 2 |
EntityInterface:: |
public | function | Deprecated way of generating a link to the entity. See toLink(). | 2 |
EntityInterface:: |
public static | function | Loads an entity. | 2 |
EntityInterface:: |
public static | function | Loads one or more entities. | 2 |
EntityInterface:: |
public | function | Acts on an entity after it is created but before hooks are invoked. | 2 |
EntityInterface:: |
public static | function | Acts on deleted entities before the delete hook is invoked. | 2 |
EntityInterface:: |
public static | function | Acts on loaded entities. | 3 |
EntityInterface:: |
public | function | Acts on a saved entity before the insert or update hook is invoked. | 2 |
EntityInterface:: |
public static | function | Changes the values of an entity before it is created. | 2 |
EntityInterface:: |
public static | function | Acts on entities before they are deleted and before hooks are invoked. | 2 |
EntityInterface:: |
public | function | Acts on an entity before the presave hook is invoked. | 2 |
EntityInterface:: |
public | function | Gets a list of entities referenced by this entity. | 2 |
EntityInterface:: |
public | function | Saves an entity permanently. | 2 |
EntityInterface:: |
public | function | Sets the original ID. | 2 |
EntityInterface:: |
public | function | Gets an array of all property values. | 3 |
EntityInterface:: |
public | function | Generates the HTML for a link to this entity. | 2 |
EntityInterface:: |
public | function | Gets the URL object for the entity. | 2 |
EntityInterface:: |
public | function | Gets a list of URI relationships supported by this entity. | 2 |
EntityInterface:: |
public | function | Gets the public URL for this entity. | 2 |
EntityInterface:: |
public | function | Gets the URL object for the entity. | 2 |
EntityInterface:: |
public | function | Gets the entity UUID (Universally Unique Identifier). | 2 |
FieldConfigInterface:: |
public | function |
Adds a validation constraint to the FieldItemList. Overrides DataDefinitionInterface:: |
1 |
FieldConfigInterface:: |
public | function | Adds constraints for a given field item property. | 1 |
FieldConfigInterface:: |
public | function | Sets the array of validation constraints for the FieldItemList. | 1 |
FieldConfigInterface:: |
public | function | Sets a default value. | 1 |
FieldConfigInterface:: |
public | function | Sets a custom default value callback. | 1 |
FieldConfigInterface:: |
public | function | Sets a human readable description. | 1 |
FieldConfigInterface:: |
public | function | Sets the field definition label. | 1 |
FieldConfigInterface:: |
public | function | Sets constraints for a given field item property. | 1 |
FieldConfigInterface:: |
public | function | Sets whether the field can be empty. | 1 |
FieldConfigInterface:: |
public | function | Sets the value for a field setting by name. | 1 |
FieldConfigInterface:: |
public | function | Sets field settings. | 1 |
FieldConfigInterface:: |
public | function | Sets whether the field is translatable. | 1 |
FieldDefinitionInterface:: |
public | function | Gets an object that can be saved in configuration. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the default value for the field in a newly created entity. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the default value callback for the field. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the default value literal for the field. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the default display options for the field. | 3 |
FieldDefinitionInterface:: |
public | function | Returns the field storage definition. | 3 |
FieldDefinitionInterface:: |
public | function | Returns the machine name of the field. | 2 |
FieldDefinitionInterface:: |
public | function | Gets the bundle the field is attached to. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the ID of the entity type the field is attached to. | 2 |
FieldDefinitionInterface:: |
public | function | Returns the field type. | 2 |
FieldDefinitionInterface:: |
public | function | Returns whether the display for the field can be configured. | 3 |
FieldDefinitionInterface:: |
public | function |
Returns whether the field can be empty. Overrides DataDefinitionInterface:: |
1 |
FieldDefinitionInterface:: |
public | function | Returns whether the field is translatable. | 2 |
ListDataDefinitionInterface:: |
public static | function | Creates a new list data definition for items of the given data type. | 2 |
ListDataDefinitionInterface:: |
public | function | Gets the data definition of an item of the list. | 2 |
RefinableCacheableDependencyInterface:: |
public | function | Adds a dependency on an object: merges its cacheability metadata. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache contexts. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Adds cache tags. | 1 |
RefinableCacheableDependencyInterface:: |
public | function | Merges the maximum age (in seconds) with the existing maximum age. | 1 |
ThirdPartySettingsInterface:: |
public | function | Gets the list of third parties that store information. | 3 |
ThirdPartySettingsInterface:: |
public | function | Gets the value of a third-party setting. | 3 |
ThirdPartySettingsInterface:: |
public | function | Gets all third-party settings of a given module. | 3 |
ThirdPartySettingsInterface:: |
public | function | Sets the value of a third-party setting. | 3 |
ThirdPartySettingsInterface:: |
public | function | Unsets a third-party setting. | 3 |