Drupal 8  8.0.2
BaseFieldOverride Class Reference
Inheritance diagram for BaseFieldOverride:

Public Member Functions

 __construct (array $values, $entity_type= 'base_field_override')
 
 getFieldStorageDefinition ()
 
 isDisplayConfigurable ($context)
 
 getDisplayOptions ($display_context)
 
 isReadOnly ()
 
 isComputed ()
 
 preSave (EntityStorageInterface $storage)
 
 __sleep ()
 
- Public Member Functions inherited from FieldConfigBase
 id ()
 
 getName ()
 
 getType ()
 
 getTargetEntityTypeId ()
 
 getTargetBundle ()
 
 onDependencyRemoval (array $dependencies)
 
 postCreate (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 getLabel ()
 
 setLabel ($label)
 
 getDescription ()
 
 setDescription ($description)
 
 isTranslatable ()
 
 setTranslatable ($translatable)
 
 getSettings ()
 
 setSettings (array $settings)
 
 getSetting ($setting_name)
 
 setSetting ($setting_name, $value)
 
 isRequired ()
 
 setRequired ($required)
 
 getDefaultValue (FieldableEntityInterface $entity)
 
 getDefaultValueLiteral ()
 
 setDefaultValue ($value)
 
 getDefaultValueCallback ()
 
 setDefaultValueCallback ($callback)
 
 __sleep ()
 
 getDataType ()
 
 isList ()
 
 getClass ()
 
 getConstraints ()
 
 getConstraint ($constraint_name)
 
 getItemDefinition ()
 
 getConfig ($bundle)
 
 setConstraints (array $constraints)
 
 addConstraint ($constraint_name, $options=NULL)
 
 setPropertyConstraints ($name, array $constraints)
 
 addPropertyConstraints ($name, array $constraints)
 
- Public Member Functions inherited from ConfigEntityBase
 __construct (array $values, $entity_type)
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 isNew ()
 
 get ($property_name)
 
 set ($property_name, $value)
 
 enable ()
 
 disable ()
 
 setStatus ($status)
 
 status ()
 
 setSyncing ($syncing)
 
 isSyncing ()
 
 setUninstalling ($uninstalling)
 
 isUninstalling ()
 
 createDuplicate ()
 
 preSave (EntityStorageInterface $storage)
 
 calculateDependencies ()
 
 urlInfo ($rel= 'edit-form', array $options=[])
 
 url ($rel= 'edit-form', $options=array())
 
 link ($text=NULL, $rel= 'edit-form', array $options=[])
 
 toUrl ($rel= 'edit-form', array $options=[])
 
 getCacheTagsToInvalidate ()
 
 getDependencies ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
 onDependencyRemoval (array $dependencies)
 
 setThirdPartySetting ($module, $key, $value)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 getThirdPartySettings ($module)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 isInstallable ()
 
 trustData ()
 
 hasTrustedData ()
 
 save ()
 
- Public Member Functions inherited from Entity
 __construct (array $values, $entity_type)
 
 id ()
 
 uuid ()
 
 isNew ()
 
 enforceIsNew ($value=TRUE)
 
 getEntityTypeId ()
 
 bundle ()
 
 label ()
 
 urlInfo ($rel= 'canonical', array $options=[])
 
 toUrl ($rel= 'canonical', array $options=[])
 
 hasLinkTemplate ($rel)
 
 link ($text=NULL, $rel= 'canonical', array $options=[])
 
 toLink ($text=NULL, $rel= 'canonical', array $options=[])
 
 url ($rel= 'canonical', $options=array())
 
 uriRelationships ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 save ()
 
 delete ()
 
 createDuplicate ()
 
 getEntityType ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 referencedEntities ()
 
 getCacheContexts ()
 
 getCacheTagsToInvalidate ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 toArray ()
 
 getTypedData ()
 
 __sleep ()
 
 getConfigDependencyKey ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
- Public Member Functions inherited from RefinableCacheableDependencyInterface
 addCacheContexts (array $cache_contexts)
 
 addCacheTags (array $cache_tags)
 
 mergeCacheMaxAge ($max_age)
 
 addCacheableDependency ($other_object)
 

Static Public Member Functions

static createFromBaseFieldDefinition (BaseFieldDefinition $base_field_definition, $bundle)
 
static loadByName ($entity_type_id, $bundle, $field_name)
 
- Static Public Member Functions inherited from FieldConfigBase
static createFromItemType ($item_type)
 
static createFromDataType ($type)
 
- Static Public Member Functions inherited from ConfigEntityBase
static sort (ConfigEntityInterface $a, ConfigEntityInterface $b)
 
- Static Public Member Functions inherited from Entity
static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
static postLoad (EntityStorageInterface $storage, array &$entities)
 
static load ($id)
 
static loadMultiple (array $ids=NULL)
 
static create (array $values=array())
 

Protected Member Functions

 getBaseFieldDefinition ()
 
- Protected Member Functions inherited from ConfigEntityBase
 getTypedConfig ()
 
 addDependency ($type, $name)
 
 invalidateTagsOnSave ($update)
 
- Protected Member Functions inherited from Entity
 entityManager ()
 
 entityTypeManager ()
 
 languageManager ()
 
 uuidGenerator ()
 
 linkTemplates ()
 
 urlRouteParameters ($rel)
 
 invalidateTagsOnSave ($update)
 

Protected Attributes

 $baseFieldDefinition
 
- Protected Attributes inherited from FieldConfigBase
 $id
 
 $field_name
 
 $field_type
 
 $entity_type
 
 $bundle
 
 $label
 
 $description = ''
 
 $settings = array()
 
 $required = FALSE
 
 $translatable = TRUE
 
 $default_value = array()
 
 $default_value_callback = ''
 
 $fieldStorage
 
 $itemDefinition
 
 $constraints = []
 
- Protected Attributes inherited from ConfigEntityBase
 $originalId
 
 $pluginConfigKey
 
 $status = TRUE
 
 $uuid
 
 $langcode = 'en'
 
 $third_party_settings = array()
 
 $_core = []
 
 $trustedData = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Additional Inherited Members

- Static Protected Member Functions inherited from ConfigEntityBase
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 
static getConfigManager ()
 
- Static Protected Member Functions inherited from Entity
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 

Detailed Description

Defines the base field override entity.

Allows base fields to be overridden on the bundle level.

( id = "base_field_override", label = ("Base field override"), handlers = { "storage" = "Drupal\Core\Field\BaseFieldOverrideStorage" }, config_prefix = "base_field_override", entity_keys = { "id" = "id", "label" = "label" }, config_export = { "id", "field_name", "entity_type", "bundle", "label", "description", "required", "translatable", "default_value", "default_value_callback", "settings", "field_type", } )

Constructor & Destructor Documentation

__construct ( array  $values,
  $entity_type = 'base_field_override' 
)

Constructs a BaseFieldOverride object.

In most cases, base field override entities are created via BaseFieldOverride::createFromBaseFieldDefinition($definition, 'bundle')

Parameters
array$valuesAn array of base field bundle override properties, keyed by property name. The field to override is specified by referring to an existing field with:
  • field_name: The field name.
  • entity_type: The entity type. Additionally, a 'bundle' property is required to indicate the entity bundle to which the bundle field override is attached to. Other array elements will be used to set the corresponding properties on the class; see the class property documentation for details.
string$entity_type(optional) The type of the entity to create. Defaults to 'base_field_override'.
See Also
entity_create()
Exceptions
\Drupal\Core\Field\FieldExceptionException thrown if $values does not contain a field_name, entity_type or bundle value.

Member Function Documentation

__sleep ( )

Implements the magic __sleep() method.

static createFromBaseFieldDefinition ( BaseFieldDefinition  $base_field_definition,
  $bundle 
)
static

Creates a base field override object.

Parameters
\Drupal\Core\Field\BaseFieldDefinition$base_field_definitionThe base field definition to override.
string$bundleThe bundle to which the override applies.
Returns
A new base field override object.

References BaseFieldDefinition\create(), and DataDefinition\toArray().

Referenced by BaseFieldDefinition\getConfig().

Here is the call graph for this function:

Here is the caller graph for this function:

getBaseFieldDefinition ( )
protected

Gets the base field definition.

Returns

References Entity\entityManager(), and FieldConfigBase\getName().

Referenced by BaseFieldOverride\getDisplayOptions(), BaseFieldOverride\getFieldStorageDefinition(), BaseFieldOverride\isComputed(), BaseFieldOverride\isDisplayConfigurable(), BaseFieldOverride\isReadOnly(), and BaseFieldOverride\preSave().

Here is the call graph for this function:

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.

References BaseFieldOverride\getBaseFieldDefinition().

Here is the call graph for this function:

getFieldStorageDefinition ( )

{Returns the field storage definition.

Returns
The field storage definition.
}

Implements FieldDefinitionInterface.

References BaseFieldOverride\getBaseFieldDefinition().

Here is the call graph for this function:

isComputed ( )

{Determines whether the data value is computed.For example, data could be computed depending on some other values.

Returns
bool Whether the data value is computed.
}

Implements DataDefinitionInterface.

References BaseFieldOverride\getBaseFieldDefinition().

Here is the call graph for this function:

isDisplayConfigurable (   $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.

References BaseFieldOverride\getBaseFieldDefinition().

Here is the call graph for this function:

isReadOnly ( )

{Determines whether the data is read-only.

Returns
bool Whether the data is read-only.
}

Implements DataDefinitionInterface.

References BaseFieldOverride\getBaseFieldDefinition().

Here is the call graph for this function:

static loadByName (   $entity_type_id,
  $bundle,
  $field_name 
)
static

Loads a base field bundle override config entity.

Parameters
string$entity_type_idID of the entity type.
string$bundleBundle name.
string$field_nameName of the field.
Returns
static The base field bundle override config entity if one exists for the provided field name, otherwise NULL.

Referenced by BaseFieldDefinition\getConfig(), and ContentTranslationSettingsTest\testSettingsUI().

Here is the caller graph for this function:

preSave ( EntityStorageInterface  $storage)

{Acts on an entity before the presave hook is invoked.Used before the entity is saved and before invoking the presave hook. Note that in case of translatable content entities this callback is only fired on their current translation. It is up to the developer to iterate over all translations if needed. This is different from its counterpart in the Field API, FieldItemListInterface::preSave(), which is fired on all field translations automatically.

Todo:
Adjust existing implementations and the documentation according to https://www.drupal.org/node/2577609 to have a consistent API.
Parameters
\Drupal\Core\Entity\EntityStorageInterface$storageThe entity storage object.
See Also
::preSave()
}

Exceptions
\Drupal\Core\Field\FieldExceptionIf the bundle is being changed.

Implements EntityInterface.

References Entity\bundle(), Entity\entityManager(), BaseFieldOverride\getBaseFieldDefinition(), FieldConfigBase\getTargetEntityTypeId(), FieldConfigBase\getType(), ConfigEntityBase\isNew(), and Drupal\service().

Here is the call graph for this function:


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