Drupal 8  8.0.2
BaseFieldDefinition Class Reference
Inheritance diagram for BaseFieldDefinition:

Public Member Functions

 getName ()
 
 setName ($name)
 
 getType ()
 
 getSettings ()
 
 setSettings (array $settings)
 
 getSetting ($setting_name)
 
 setSetting ($setting_name, $value)
 
 getProvider ()
 
 setProvider ($provider)
 
 isTranslatable ()
 
 setTranslatable ($translatable)
 
 isRevisionable ()
 
 setRevisionable ($revisionable)
 
 getCardinality ()
 
 setCardinality ($cardinality)
 
 isMultiple ()
 
 isQueryable ()
 
 setQueryable ($queryable)
 
 setPropertyConstraints ($name, array $constraints)
 
 addPropertyConstraints ($name, array $constraints)
 
 setDisplayOptions ($display_context, array $options)
 
 setDisplayConfigurable ($display_context, $configurable)
 
 getDisplayOptions ($display_context)
 
 isDisplayConfigurable ($display_context)
 
 getDefaultValueLiteral ()
 
 getDefaultValueCallback ()
 
 getDefaultValue (FieldableEntityInterface $entity)
 
 setDefaultValue ($value)
 
 setDefaultValueCallback ($callback)
 
 getOptionsProvider ($property_name, FieldableEntityInterface $entity)
 
 getPropertyDefinition ($name)
 
 getPropertyDefinitions ()
 
 getPropertyNames ()
 
 getMainPropertyName ()
 
 __sleep ()
 
 getTargetEntityTypeId ()
 
 setTargetEntityTypeId ($entity_type_id)
 
 getTargetBundle ()
 
 setTargetBundle ($bundle)
 
 getSchema ()
 
 getColumns ()
 
 hasCustomStorage ()
 
 isBaseField ()
 
 setCustomStorage ($custom_storage)
 
 getFieldStorageDefinition ()
 
 getUniqueStorageIdentifier ()
 
 getConfig ($bundle)
 
- Public Member Functions inherited from ListDataDefinition
 __construct (array $values=array(), DataDefinitionInterface $item_definition=NULL)
 
 getDataType ()
 
 setDataType ($type)
 
 getClass ()
 
 getItemDefinition ()
 
 setItemDefinition (DataDefinitionInterface $definition)
 
- Public Member Functions inherited from DataDefinition
 __construct (array $values=array())
 
 getDataType ()
 
 setDataType ($type)
 
 getLabel ()
 
 setLabel ($label)
 
 getDescription ()
 
 setDescription ($description)
 
 isList ()
 
 isReadOnly ()
 
 setReadOnly ($read_only)
 
 isComputed ()
 
 setComputed ($computed)
 
 isRequired ()
 
 setRequired ($required)
 
 getClass ()
 
 setClass ($class)
 
 getSettings ()
 
 setSettings (array $settings)
 
 getSetting ($setting_name)
 
 setSetting ($setting_name, $value)
 
 getConstraints ()
 
 getConstraint ($constraint_name)
 
 setConstraints (array $constraints)
 
 addConstraint ($constraint_name, $options=NULL)
 
 offsetExists ($offset)
 
offsetGet ($offset)
 
 offsetSet ($offset, $value)
 
 offsetUnset ($offset)
 
 toArray ()
 
- Public Member Functions inherited from FieldDefinitionInterface
 isRequired ()
 
- Public Member Functions inherited from CacheableDependencyInterface
 getCacheContexts ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
- Public Member Functions inherited from FieldStorageDefinitionInterface
 getLabel ()
 
 getDescription ()
 
 getConstraints ()
 
 getConstraint ($constraint_name)
 

Static Public Member Functions

static create ($type)
 
static createFromFieldStorageDefinition (FieldStorageDefinitionInterface $definition)
 
static createFromItemType ($item_type)
 
- Static Public Member Functions inherited from ListDataDefinition
static create ($item_type)
 
static createFromDataType ($type)
 
static createFromItemType ($item_type)
 
- Static Public Member Functions inherited from DataDefinition
static create ($type)
 
static createFromDataType ($type)
 

Protected Member Functions

 getFieldItemClass ()
 

Protected Attributes

 $type
 
 $propertyDefinitions
 
 $schema
 
 $indexes = array()
 
- Protected Attributes inherited from ListDataDefinition
 $itemDefinition
 
- Protected Attributes inherited from DataDefinition
 $definition = array()
 

Additional Inherited Members

- Data Fields inherited from FieldStorageDefinitionInterface
const CARDINALITY_UNLIMITED = -1
 

Detailed Description

A class for defining entity fields.

Member Function Documentation

__sleep ( )

{}

addPropertyConstraints (   $name,
array  $constraints 
)

Adds constraints for a given field item property.

Adds a constraint to a property of a base field item. e.g.

// Limit the field item's value property to the range 0 through 10.
// e.g. $node->size->value.
$field->addPropertyConstraints('value', [
'Range' => [
'min' => 0,
'max' => 10,
]
]);

If you want to add a validation constraint that applies to the , use BaseFieldDefinition::addConstraint() instead.

Note: passing a new set of options for an existing property constraint will overwrite with the new options.

Parameters
string$nameThe name of the property to set constraints for.
array$constraintsThe constraints to set.
Returns
static The object itself for chaining.
See Also
::addConstraint()

References ListDataDefinition\getItemDefinition().

Here is the call graph for this function:

static create (   $type)
static

Creates a new field definition.

Parameters
string$typeThe type of the field.
Returns
static A new field definition object.

References FieldItemDataDefinition\create(), and Drupal\service().

Referenced by EntityTestDefaultValue\baseFieldDefinitions(), NoLanguageEntityTest\baseFieldDefinitions(), EntityTestConstraints\baseFieldDefinitions(), EntityTestStringId\baseFieldDefinitions(), EntityTestBaseFieldDisplay\baseFieldDefinitions(), EntityTestMulDefaultValue\baseFieldDefinitions(), Item\baseFieldDefinitions(), EntityTestRev\baseFieldDefinitions(), EntityTestMulRevChanged\baseFieldDefinitions(), EntityTestMulChanged\baseFieldDefinitions(), EntityTest\baseFieldDefinitions(), Term\baseFieldDefinitions(), Shortcut\baseFieldDefinitions(), Feed\baseFieldDefinitions(), Message\baseFieldDefinitions(), BlockContent\baseFieldDefinitions(), Comment\baseFieldDefinitions(), File\baseFieldDefinitions(), MenuLinkContent\baseFieldDefinitions(), Node\baseFieldDefinitions(), User\baseFieldDefinitions(), BaseFieldOverride\createFromBaseFieldDefinition(), FieldItemDataDefinition\createFromDataType(), ContentTranslationHandler\getFieldDefinitions(), Sql\getFieldSchema(), BaseFieldDefinitionTestBase\setUp(), FieldModuleUninstallValidatorTest\setUp(), ContentEntityBaseUnitTest\setUp(), EntityAdapterUnitTest\setUp(), EntityViewsDataTest\setupBaseFields(), FieldSettingsTest\testBaseFieldSettings(), EntityViewsDataTest\testBaseTableFields(), BaseFieldDefinitionTest\testCustomStorage(), EntityViewsDataTest\testDataTableFields(), BaseFieldDefinitionTest\testDefaultFieldSettings(), BaseFieldDefinitionTest\testDefaultValueCallback(), BaseFieldDefinitionTest\testFieldCardinality(), BaseFieldDefinitionTest\testFieldDefaultValue(), BaseFieldDefinitionTest\testFieldDescription(), BaseFieldDefinitionTest\testFieldLabel(), BaseFieldDefinitionTest\testFieldName(), BaseFieldDefinitionTest\testFieldProvider(), BaseFieldDefinitionTest\testFieldRequired(), BaseFieldDefinitionTest\testFieldRevisionable(), EntityTypedDataDefinitionTest\testFields(), BaseFieldDefinitionTest\testFieldSettings(), BaseFieldDefinitionTest\testFieldTranslatable(), BaseFieldDefinitionTest\testFieldType(), BaseFieldDefinitionTest\testInvalidDefaultValueCallback(), BaseFieldDefinitionTest\testNullDefaultValueCallback(), EntityViewsDataTest\testRevisionTableFields(), EntityDefinitionUpdateTest\testSingleActionCalls(), TypedDataTest\testTypedDataValidation(), and ValidReferenceConstraintValidatorTest\testValidation().

Here is the call graph for this function:

static createFromFieldStorageDefinition ( FieldStorageDefinitionInterface  $definition)
static

Creates a new field definition based upon a field storage definition.

In cases where one needs a field storage definitions to act like full field definitions, this creates a new field definition based upon the (limited) information available. That way it is possible to use the field definition in places where a full field definition is required; e.g., with widgets or formatters.

Parameters
\Drupal\Core\Field\FieldStorageDefinitionInterface$definitionThe field storage definition to base the new field definition upon.
Returns
$this

References FieldStorageDefinitionInterface\getCardinality(), FieldStorageDefinitionInterface\getConstraints(), FieldStorageDefinitionInterface\getDescription(), FieldStorageDefinitionInterface\getLabel(), FieldStorageDefinitionInterface\getName(), FieldStorageDefinitionInterface\getProvider(), FieldStorageDefinitionInterface\getSettings(), FieldStorageDefinitionInterface\getTargetEntityTypeId(), FieldStorageDefinitionInterface\getType(), FieldStorageDefinitionInterface\hasCustomStorage(), FieldStorageDefinitionInterface\isQueryable(), FieldStorageDefinitionInterface\isRevisionable(), FieldStorageDefinitionInterface\isTranslatable(), BaseFieldDefinition\setCardinality(), DataDefinition\setConstraints(), BaseFieldDefinition\setCustomStorage(), DataDefinition\setDescription(), DataDefinition\setLabel(), BaseFieldDefinition\setName(), BaseFieldDefinition\setProvider(), BaseFieldDefinition\setQueryable(), BaseFieldDefinition\setRevisionable(), BaseFieldDefinition\setSettings(), BaseFieldDefinition\setTargetEntityTypeId(), and BaseFieldDefinition\setTranslatable().

Here is the call graph for this function:

static createFromItemType (   $item_type)
static

{Creates a new list data definition for items of the given data type.This method is typically used by ::createListDataDefinition() to build a definition object for an arbitrary item type. When the definition class is known, it is recommended to directly use the static create() method on that class instead; e.g.:

Parameters
string$item_typeThe item type, for which a list data definition should be created.
Returns
static
Exceptions
\InvalidArgumentExceptionIf an unsupported data type gets passed to the class; e.g., 'string' to a definition class handling lists of 'field_item:* data types.
}

Implements ListDataDefinitionInterface.

Referenced by FieldConfigBase\createFromItemType().

Here is the caller graph for this function:

getCardinality ( )

{Returns the maximum number of items allowed for the field.Possible values are positive integers or FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED.

Returns
int The field cardinality.
}

Implements FieldStorageDefinitionInterface.

Referenced by BaseFieldDefinition\isMultiple().

Here is the caller graph for this function:

getColumns ( )

{Returns the field columns, as defined in the field schema.

Returns
array[] The array of field columns, keyed by column name, in the same format returned by getSchema().
See Also
::getSchema()
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getSchema().

Here is the call graph for this function:

getConfig (   $bundle)

{Gets an object that can be saved in configuration.Base fields are defined in code. In order to configure field definition properties per bundle use this method to create an override that can be saved in configuration.

See Also
Parameters
string$bundleThe bundle to get the configurable field for.
Returns
}

Implements FieldDefinitionInterface.

References BaseFieldOverride\createFromBaseFieldDefinition(), BaseFieldDefinition\getName(), BaseFieldDefinition\getTargetEntityTypeId(), and BaseFieldOverride\loadByName().

Here is the call graph for this function:

getDefaultValue ( FieldableEntityInterface  $entity)

{Returns the default value for the field in a newly created entity.This method computes the runtime default value for a field in a given entity. To access the raw properties assigned to the field definition, ::getDefaultValueLiteral() or ::getDefaultValueCallback() should be used instead.

Parameters
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity for which the default value is generated.
Returns
array The default value for the field, as a numerically indexed array of items, each item being a property/value array (array() for no default value).
See Also
FieldDefinitionInterface::getDefaultValueLiteral()
FieldDefinitionInterface::getDefaultValueCallback()
}

Implements FieldDefinitionInterface.

References ListDataDefinition\getClass(), BaseFieldDefinition\getDefaultValueCallback(), BaseFieldDefinition\getDefaultValueLiteral(), and BaseFieldDefinition\getPropertyNames().

Here is the call graph for this function:

getDefaultValueCallback ( )

{Returns the default value callback for the field.This method retrieves the raw property assigned to the field definition. When computing the runtime default value for a field in a given entity, ::getDefaultValue() should be used instead.

Returns
string|null The default value callback for the field.
See Also
FieldDefinitionInterface::getDefaultValue()
FieldDefinitionInterface::getDefaultValueLiteral()
}

Implements FieldDefinitionInterface.

Referenced by BaseFieldDefinition\getDefaultValue().

Here is the caller graph for this function:

getDefaultValueLiteral ( )

{Returns the default value literal for the field.This method retrieves the raw property assigned to the field definition. When computing the runtime default value for a field in a given entity, ::getDefaultValue() should be used instead.

Returns
array The default value for the field, as a numerically indexed array of items, each item being a property/value array (array() for no default value).
See Also
FieldDefinitionInterface::getDefaultValue()
FieldDefinitionInterface::getDefaultValueCallback()
}

Implements FieldDefinitionInterface.

Referenced by BaseFieldDefinition\getDefaultValue().

Here is the caller graph for this function:

getDisplayOptions (   $display_context)

{Returns the default display options for the field.If the field's display is configurable, the returned display options act as default values and may be overridden via the respective entity display. Otherwise, the display options will be applied to entity displays as is.

Parameters
string$display_contextThe display context. Either 'view' or 'form'.
Returns
array|null The array of display options for the field, or NULL if the field is not displayed. The following key/value pairs may be present:
  • label: (string) Position of the field label. The default 'field' theme implementation supports the values 'inline', 'above' and 'hidden'. Defaults to 'above'. Only applies to 'view' context.
  • type: (string) The plugin (widget or formatter depending on $display_context) to use, or 'hidden'. If not specified or if the requested plugin is unknown, the 'default_widget' / 'default_formatter' for the field type will be used.
  • settings: (array) Settings for the plugin specified above. The default settings for the plugin will be used for settings left unspecified.
  • third_party_settings: (array) Settings provided by other extensions through hook_field_formatter_third_party_settings_form().
  • weight: (float) The weight of the element. Not needed if 'type' is 'hidden'. The defaults of the various display options above get applied by the used entity display.
See Also
}

Implements FieldDefinitionInterface.

getFieldItemClass ( )
protected

Helper to retrieve the field item class.

Todo:
: Remove once getClass() adds in defaults. See https://www.drupal.org/node/2116341.

References ListDataDefinition\getClass(), ListDataDefinition\getDataType(), ListDataDefinition\getItemDefinition(), and Drupal\typedDataManager().

Referenced by BaseFieldDefinition\getMainPropertyName(), BaseFieldDefinition\getOptionsProvider(), and BaseFieldDefinition\getPropertyDefinitions().

Here is the call graph for this function:

Here is the caller graph for this function:

getFieldStorageDefinition ( )

{Returns the field storage definition.

Returns
The field storage definition.
}

Implements FieldDefinitionInterface.

getMainPropertyName ( )

{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

target_id

of an entity reference. If the field item has no main property, the method returns NULL.

Returns
string|null The name of the value property, or NULL if there is none.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getFieldItemClass().

Referenced by BaseFieldDefinition\setDefaultValue().

Here is the call graph for this function:

Here is the caller graph for this function:

getName ( )

{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.

Returns
string The field name.
}

Implements FieldDefinitionInterface.

Referenced by BaseFieldDefinition\getConfig(), BaseFieldDefinition\getOptionsProvider(), and BaseFieldDefinition\getUniqueStorageIdentifier().

Here is the caller graph for this function:

getOptionsProvider (   $property_name,
FieldableEntityInterface  $entity 
)

{Gets an options provider for the given field item property.

Parameters
string$property_nameThe name of the property to get options for; e.g., 'value'.
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity for which the options should be provided.
Returns
|null An options provider, or NULL if no options are defined.
}

Implements FieldStorageDefinitionInterface.

References FieldableEntityInterface\get(), BaseFieldDefinition\getFieldItemClass(), and BaseFieldDefinition\getName().

Here is the call graph for this function:

getPropertyDefinition (   $name)

{Gets the definition of a contained property.

Parameters
string$nameThe name of property.
Returns
|null The definition of the property or NULL if the property does not exist.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getPropertyDefinitions().

Here is the call graph for this function:

getPropertyDefinitions ( )

{Gets an array of property definitions of contained properties.

Returns
[] An array of property definitions of contained properties, keyed by property name.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getFieldItemClass().

Referenced by BaseFieldDefinition\getPropertyDefinition(), and BaseFieldDefinition\getPropertyNames().

Here is the call graph for this function:

Here is the caller graph for this function:

getPropertyNames ( )

{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.

Returns
string[] The property names.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getPropertyDefinitions().

Referenced by BaseFieldDefinition\getDefaultValue().

Here is the call graph for this function:

Here is the caller graph for this function:

getProvider ( )

{Returns the name of the provider of this field.

Returns
string The provider name; e.g., the module name.
}

Implements FieldStorageDefinitionInterface.

getSchema ( )

{Returns the field schema.Note that this method returns an empty array for computed fields which have no schema.

Returns
array[] The field schema, as an array of key/value pairs in the format returned by hook_field_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.
  • 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.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getType(), and Drupal\service().

Referenced by BaseFieldDefinition\getColumns().

Here is the call graph for this function:

Here is the caller graph for this function:

getSetting (   $setting_name)

{Returns the value of a given storage setting.

Parameters
string$setting_nameThe setting name.
Returns
mixed The setting value.
}

Implements FieldStorageDefinitionInterface.

References ListDataDefinition\getItemDefinition().

Here is the call graph for this function:

getSettings ( )

{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.

Returns
mixed[] An array of key/value pairs.
}

Implements FieldStorageDefinitionInterface.

References ListDataDefinition\getItemDefinition().

Here is the call graph for this function:

getTargetBundle ( )

{Gets the bundle the field is attached to.This method should not be confused with EntityInterface::bundle() (configurable fields are config entities, and thus implement both interfaces):

Returns
string|null The bundle the field is defined for, or NULL if it is a base field; i.e., it is not bundle-specific.
}

Implements FieldDefinitionInterface.

getTargetEntityTypeId ( )

{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):

Returns
string The entity type ID.
}

Implements FieldDefinitionInterface.

Referenced by BaseFieldDefinition\getConfig(), and BaseFieldDefinition\getUniqueStorageIdentifier().

Here is the caller graph for this function:

getType ( )

{Returns the field type.

Returns
string The field type, i.e. the id of a field type plugin. For example 'text'.
See Also
}

Implements FieldDefinitionInterface.

Referenced by BaseFieldDefinition\getSchema().

Here is the caller graph for this function:

getUniqueStorageIdentifier ( )

{Returns a unique identifier for the field.

Returns
string
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getName(), and BaseFieldDefinition\getTargetEntityTypeId().

Here is the call graph for this function:

hasCustomStorage ( )

{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.

Returns
bool FALSE if the storage takes care of storing the field, TRUE otherwise.
}

Implements FieldStorageDefinitionInterface.

References DataDefinition\isComputed().

Here is the call graph for this function:

isBaseField ( )

{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.

Returns
bool Whether the field is a base field.
}

Implements FieldStorageDefinitionInterface.

isDisplayConfigurable (   $display_context)

{Returns whether the display for the field can be configured.

Parameters
string$display_contextThe display context. Either 'view' or 'form'.
Returns
bool TRUE if the display for this field is configurable in the given context. If TRUE, the display options returned by getDisplayOptions() may be overridden via the respective entity display.
See Also
}

Implements FieldDefinitionInterface.

isMultiple ( )

{Returns whether the field can contain multiple items.

Returns
bool TRUE if the field can contain multiple items, FALSE otherwise.
}

Implements FieldStorageDefinitionInterface.

References BaseFieldDefinition\getCardinality().

Here is the call graph for this function:

isQueryable ( )

{Determines whether the field is queryable via QueryInterface.

Returns
bool TRUE if the field is queryable.
}

Implements FieldStorageDefinitionInterface.

References DataDefinition\isComputed().

Here is the call graph for this function:

isRevisionable ( )

{Returns whether the field is revisionable.

Returns
bool TRUE if the field is revisionable.
}

Implements FieldStorageDefinitionInterface.

isTranslatable ( )

{Returns whether the field is translatable.

Returns
bool TRUE if the field is translatable.
}

Implements FieldDefinitionInterface.

setCardinality (   $cardinality)

Sets the maximum number of items allowed for the field.

Possible values are positive integers or FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED.

Parameters
int$cardinalityThe field cardinality.
Returns
$this

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setCustomStorage (   $custom_storage)

Sets the storage behavior for this field.

Parameters
bool$custom_storagePass FALSE if the storage takes care of storing the field, TRUE otherwise.
Returns
$this
Exceptions
\LogicExceptionThrown if custom storage is to be set to FALSE for a computed field.

References DataDefinition\isComputed().

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the call graph for this function:

Here is the caller graph for this function:

setDefaultValue (   $value)

{}

References BaseFieldDefinition\getMainPropertyName().

Here is the call graph for this function:

setDefaultValueCallback (   $callback)

{}

setDisplayConfigurable (   $display_context,
  $configurable 
)

Sets whether the display for the field can be configured.

Parameters
string$display_contextThe display context. Either 'view' or 'form'.
bool$configurableWhether the display options can be configured (e.g., via the "Manage display" / "Manage form display" UI screens). If TRUE, the options specified via getDisplayOptions() act as defaults.
Returns
static The object itself for chaining.
setDisplayOptions (   $display_context,
array  $options 
)

Sets the display options for the field in forms or rendered entities.

This enables generic rendering of the field with widgets / formatters, including automated support for "In place editing", and with optional configurability in the "Manage display" / "Manage form display" UI screens.

Unless this method is called, the field remains invisible (or requires ad-hoc rendering logic).

Parameters
string$display_contextThe display context. Either 'view' or 'form'.
array$optionsAn array of display options. Refer to ::getDisplayOptions() for a list of supported keys. The options should include at least a 'weight', or specify 'type' = 'hidden'. The 'default_widget' / 'default_formatter' for the field type will be used if no 'type' is specified.
Returns
static The object itself for chaining.
setName (   $name)

Sets the field name.

Parameters
string$nameThe field name to set.
Returns
static The object itself for chaining.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setPropertyConstraints (   $name,
array  $constraints 
)

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 ::addPropertyConstraints()

Parameters
string$nameThe name of the property to set constraints for.
array$constraintsThe constraints to set.
Returns
static The object itself for chaining.

References ListDataDefinition\getItemDefinition().

Here is the call graph for this function:

setProvider (   $provider)

Sets the name of the provider of this field.

Parameters
string$providerThe provider name to set.
Returns
$this

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setQueryable (   $queryable)

Sets whether the field is queryable.

Parameters
bool$queryableWhether the field is queryable.
Returns
static The object itself for chaining.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setRevisionable (   $revisionable)

Sets whether the field is revisionable.

Parameters
bool$revisionableWhether the field is revisionable.
Returns
$this The object itself for chaining.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setSetting (   $setting_name,
  $value 
)

{}

References ListDataDefinition\getItemDefinition().

Here is the call graph for this function:

setSettings ( array  $settings)

{}

Note that the method does not unset existing settings not specified in the incoming $settings array.

For example:

// 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',
];

For clarity, it is preferred to use setSetting() if not all available settings are supplied.

References ListDataDefinition\getItemDefinition().

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the call graph for this function:

Here is the caller graph for this function:

setTargetBundle (   $bundle)

Sets the bundle this field is defined for.

Parameters
string | null$bundleThe bundle, or NULL if the field is not bundle-specific.
Returns
$this
setTargetEntityTypeId (   $entity_type_id)

Sets the ID of the type of the entity this field is attached to.

Parameters
string$entity_type_idThe name of the target entity type to set.
Returns
$this

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:

setTranslatable (   $translatable)

Sets whether the field is translatable.

Parameters
bool$translatableWhether the field is translatable.
Returns
$this The object itself for chaining.

Implements FieldStorageDefinitionInterface.

Referenced by BaseFieldDefinition\createFromFieldStorageDefinition().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: