Drupal 8  8.0.2
ConfigEntityBase Class Reference
Inheritance diagram for ConfigEntityBase:

Public Member Functions

 __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 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

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

Static Protected Member Functions

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

Protected Attributes

 $originalId
 
 $pluginConfigKey
 
 $status = TRUE
 
 $uuid
 
 $langcode = 'en'
 
 $third_party_settings = array()
 
 $_core = []
 
 $trustedData = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Detailed Description

Defines a base configuration entity class.

Constructor & Destructor Documentation

__construct ( array  $values,
  $entity_type 
)

{}

References Entity\id(), and ConfigEntityBase\setOriginalId().

Here is the call graph for this function:

Member Function Documentation

addDependency (   $type,
  $name 
)
protected

Overrides :addDependency().

Note that this function should only be called from implementations of ::calculateDependencies(), as dependencies are recalculated during every entity save.

See Also
::hasDependency()

References Entity\getEntityType().

Referenced by EntityDisplayModeBase\calculateDependencies(), Editor\calculateDependencies(), RdfMapping\calculateDependencies(), Tour\calculateDependencies(), FieldConfig\calculateDependencies(), ContentLanguageSettings\calculateDependencies(), ResponsiveImageStyle\calculateDependencies(), Block\calculateDependencies(), EntityDisplayBase\calculateDependencies(), View\calculateDependencies(), FieldStorageConfig\calculateDependencies(), ConfigEntityBase\calculateDependencies(), and Migration\calculateDependencies().

Here is the call graph for this function:

Here is the caller graph for this function:

calculateDependencies ( )

{Calculates dependencies and stores them in the dependency property.

Returns
$this
See Also
}

Implements ConfigEntityInterface.

References ConfigEntityBase\addDependency(), and ConfigEntityBase\getThirdPartyProviders().

Referenced by ConfigEntityBase\preSave().

Here is the call graph for this function:

Here is the caller graph for this function:

createDuplicate ( )

{Creates a duplicate of the entity.

Returns
static A clone of $this with all identifiers unset, so saving it inserts a new entity into the storage system.
}

Implements EntityInterface.

Referenced by EntityDisplayBase\createCopy().

Here is the caller graph for this function:

disable ( )

{Disables the configuration entity.

Returns
$this
}

Implements ConfigEntityInterface.

References ConfigEntityBase\setStatus().

Referenced by ConfigTestController\disable().

Here is the call graph for this function:

Here is the caller graph for this function:

enable ( )

{Enables the configuration entity.

Returns
$this
}

Implements ConfigEntityInterface.

References ConfigEntityBase\setStatus().

Referenced by ConfigTestController\enable().

Here is the call graph for this function:

Here is the caller graph for this function:

get (   $property_name)

{Returns the value of a property.

Parameters
string$property_nameThe name of the property that should be returned.
Returns
mixed The property if it exists, or NULL otherwise.
}

Implements ConfigEntityInterface.

getCacheTagsToInvalidate ( )

{Returns the cache tags that should be used to invalidate caches.This will not return additional cache tags added through addCacheTags().

Returns
string[] Set of cache tags.
See Also
::addCacheTags()
::getCacheTags()
}

Implements EntityInterface.

References ConfigEntityBase\getConfigDependencyName().

Referenced by ImageStyle\flush(), and Block\postSave().

Here is the call graph for this function:

Here is the caller graph for this function:

getConfigDependencyName ( )

{Gets the configuration dependency name.Configuration entities can depend on content and configuration entities. They store an array of content and config dependency names in their "dependencies" key.

Returns
string The configuration dependency name.
See Also
}

Implements EntityInterface.

References Entity\getEntityType(), and Entity\id().

Referenced by Editor\calculateDependencies(), FieldConfig\calculateDependencies(), and ConfigEntityBase\getCacheTagsToInvalidate().

Here is the call graph for this function:

Here is the caller graph for this function:

static getConfigManager ( )
staticprotected

Gets the configuration manager.

Returns
The configuration manager.
getConfigTarget ( )

{Gets the configuration target identifier for the entity.Used to supply the correct format for storing a reference targeting this entity in configuration.

Returns
string The configuration target identifier.
}

Implements EntityInterface.

References Entity\id().

Here is the call graph for this function:

getDependencies ( )

{Gets the configuration dependencies.

Returns
array An array of dependencies, keyed by $type.
See Also
}

Implements ConfigEntityInterface.

References NestedArray\mergeDeep().

Here is the call graph for this function:

getOriginalId ( )

{Gets the original ID.

Returns
int|string|null The original ID, or NULL if no ID was set or for entity types that do not support renames.
}

Implements EntityInterface.

Referenced by ConfigEntityBundleBase\loadDisplays(), NodeType\postSave(), ConfigEntityBundleBase\preSave(), and ConfigEntityBase\preSave().

Here is the caller graph for this function:

getThirdPartyProviders ( )

{Gets the list of third parties that store information.

Returns
array The list of third parties.
}

Implements ThirdPartySettingsInterface.

Referenced by ConfigEntityBase\calculateDependencies().

Here is the caller graph for this function:

getThirdPartySetting (   $module,
  $key,
  $default = NULL 
)

{Gets the value of a third-party setting.

Parameters
string$moduleThe module providing the third-party setting.
string$keyThe setting name.
mixed$defaultThe default value
Returns
mixed The value.
}

Implements ThirdPartySettingsInterface.

getThirdPartySettings (   $module)

{Gets all third-party settings of a given module.

Parameters
string$moduleThe module providing the third-party settings.
Returns
array An array of key-value pairs.
}

Implements ThirdPartySettingsInterface.

getTypedConfig ( )
protected

Gets the typed config manager.

Returns
hasTrustedData ( )

{Gets whether on not the data is trusted.

Returns
bool TRUE if the configuration data is trusted, FALSE if not.
}

Implements ConfigEntityInterface.

static invalidateTagsOnDelete ( EntityTypeInterface  $entity_type,
array  $entities 
)
staticprotected

{}

Override to never invalidate the individual entities' cache tags; the config system already invalidates them.

References EntityTypeInterface\getListCacheTags(), and Cache\invalidateTags().

Here is the call graph for this function:

invalidateTagsOnSave (   $update)
protected

{}

Override to never invalidate the entity's cache tag; the config system already invalidates it.

References Entity\getEntityType(), and Cache\invalidateTags().

Here is the call graph for this function:

isInstallable ( )

{Checks whether this entity is installable.For example, a default view might not be installable if the base table doesn't exist.bool TRUE if the entity is installable, FALSE otherwise.}

Implements ConfigEntityInterface.

isNew ( )

Overrides Entity::isNew().

EntityInterface::enforceIsNew() is only supported for newly created configuration entities but has no effect after saving, since each configuration entity is unique.

Implements EntityInterface.

References Entity\enforceIsNew().

Referenced by ConfigEntityBundleBase\preSave(), FieldConfig\preSave(), BaseFieldOverride\preSave(), FieldStorageConfig\preSave(), and ConfigEntityBase\preSave().

Here is the call graph for this function:

Here is the caller graph for this function:

isSyncing ( )

{Returns whether this entity is being changed as part of an import process.If you are writing code that responds to a change in this entity (insert, update, delete, presave, etc.), and your code would result in a configuration change (whether related to this configuration entity, another configuration entity, or non-entity configuration) or your code would result in a change to this entity itself, you need to check and see if this entity change is part of an import process, and skip executing your code if that is the case.For example, ::postSave() adds the default body field to newly created node type configuration entities, which is a configuration change. You would not want this code to run during an import, because imported entities were already given the body field when they were originally created, and the imported configuration includes all of their currently-configured fields. On the other hand, ::preSave() and the methods it calls make sure that the storage tables are created or updated for the field storage configuration entity, which is not a configuration change, and it must be done whether due to an import or not. So, the first method should check $entity->isSyncing() and skip executing if it returns TRUE, and the second should not perform this check.

Returns
bool TRUE if the configuration entity is being created, updated, or deleted through the import process.
}

Implements ConfigEntityInterface.

Referenced by Vocabulary\postDelete(), ShortcutSet\postSave(), ImageStyle\postSave(), ConfigurableLanguage\postSave(), FilterFormat\postSave(), View\preSave(), ConfigEntityBase\preSave(), and ConfigEntityBase\setSyncing().

Here is the caller graph for this function:

isUninstalling ( )

{Returns whether this entity is being changed during the uninstall process.If you are writing code that responds to a change in this entity (insert, update, delete, presave, etc.), and your code would result in a configuration change (whether related to this configuration entity, another configuration entity, or non-entity configuration) or your code would result in a change to this entity itself, you need to check and see if this entity change is part of an uninstall process, and skip executing your code if that is the case.For example, ::preDelete() prevents the API from deleting the default language. However during an uninstall of the language module it is expected that the default language should be deleted.

Returns
bool
}

Implements ConfigEntityInterface.

Referenced by ConfigEntityBase\setUninstalling().

Here is the caller graph for this function:

link (   $text = NULL,
  $rel = 'edit-form',
array  $options = [] 
)

{Deprecated way of generating a link to the entity. See toLink().

Parameters
string | null$text(optional) The link text for the anchor tag as a translated string. If NULL, it will use the entity's label. Defaults to NULL.
string$rel(optional) The link relationship type. Defaults to 'canonical'.
array$optionsSee ::generateFromRoute() for the available options.
Returns
string An HTML string containing a link to the entity.
Deprecated:
in Drupal 8.0.0, intended to be removed in Drupal 9.0.0 Please use toLink() instead.
See Also
::toLink
}

Implements EntityInterface.

onDependencyRemoval ( array  $dependencies)

{Informs the entity that entities it depends on will be deleted.This method allows configuration entities to remove dependencies instead of being deleted themselves. Configuration entities can use this method to avoid being unnecessarily deleted during an extension uninstallation. For example, entity displays remove references to widgets and formatters if the plugin that supplies them depends on a module that is being uninstalled.If this method returns TRUE then the entity needs to be re-saved by the caller for the changes to take effect. Implementations should not save the entity.

Parameters
array$dependenciesAn array of dependencies that will be deleted keyed by dependency type. Dependency types are, for example, entity, module and theme.
Returns
bool TRUE if the entity has changed, FALSE if not.
bool TRUE if the entity has been changed as a result, FALSE if not.
See Also
::preDelete()
::uninstall()
::onDependencyRemoval()
}

Implements ConfigEntityInterface.

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()
}

Implements EntityInterface.

References ConfigEntityBase\calculateDependencies(), ConfigEntityBase\getOriginalId(), EntityStorageInterface\getQuery(), ConfigEntityBase\isNew(), ConfigEntityBase\isSyncing(), EntityStorageInterface\loadUnchanged(), ConfigEntityBase\set(), and Entity\uuid().

Here is the call graph for this function:

save ( )

{Saves an entity permanently.When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

Returns
int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.
Exceptions
\Drupal\Core\Entity\EntityStorageExceptionIn case of failures an exception is thrown.
}

Implements EntityInterface.

Referenced by ImageStyle\deleteImageEffect().

Here is the caller graph for this function:

set (   $property_name,
  $value 
)

{Sets the value of a property.

Parameters
string$property_nameThe name of the property that should be set.
mixed$valueThe value the property should be set to.
Returns
$this
}

Implements ConfigEntityInterface.

Referenced by View\duplicateDisplayAsType(), View\mergeDefaultDisplaysOptions(), View\preSave(), ConfigEntityBase\preSave(), ImageStyle\setName(), EntityDisplayBase\setTargetBundle(), and Role\setWeight().

Here is the caller graph for this function:

setOriginalId (   $id)

{Sets the original ID.

Parameters
int | string | null$idThe new ID to set as original ID. If the entity supports renames, setting NULL will prevent an update from being considered a rename.
Returns
$this
}

Implements EntityInterface.

Referenced by ConfigEntityBase\__construct().

Here is the caller graph for this function:

setStatus (   $status)

{Sets the status of the configuration entity.

Parameters
bool$statusThe status of the configuration entity.
Returns
$this
}

Implements ConfigEntityInterface.

References ConfigEntityBase\status().

Referenced by ConfigEntityBase\disable(), and ConfigEntityBase\enable().

Here is the call graph for this function:

Here is the caller graph for this function:

setSyncing (   $syncing)

{Sets the status of the isSyncing flag.

Parameters
bool$statusThe status of the sync flag.
Returns
$this
}

Implements ConfigEntityInterface.

References ConfigEntityBase\isSyncing().

Here is the call graph for this function:

setThirdPartySetting (   $module,
  $key,
  $value 
)

{Sets the value of a third-party setting.

Parameters
string$moduleThe module providing the third-party setting.
string$keyThe setting name.
mixed$valueThe setting value.
Returns
$this
}

Implements ThirdPartySettingsInterface.

setUninstalling (   $uninstalling)

{}

References ConfigEntityBase\isUninstalling().

Here is the call graph for this function:

static sort ( ConfigEntityInterface  $a,
ConfigEntityInterface  $b 
)
static

Helper callback for uasort() to sort configuration entities by weight and label.

References EntityInterface\label().

Here is the call graph for this function:

status ( )

{Returns whether the configuration entity is enabled.Status implementations for configuration entities should follow these general rules:

  • Status does not affect the loading of entities. I.e. Disabling configuration entities should only have UI/access implications.
  • It should only take effect when a 'status' key is explicitly declared in the entity_keys info of a configuration entity's annotation data.
  • Each entity implementation (entity/controller) is responsible for checking and managing the status.
Returns
bool Whether the entity is enabled or not.
}

Implements ConfigEntityInterface.

Referenced by SearchPage\isIndexable(), View\postSave(), and ConfigEntityBase\setStatus().

Here is the caller graph for this function:

toUrl (   $rel = 'edit-form',
array  $options = [] 
)

{Gets the URL object for the entity.The entity must have an id already. Content entities usually get their IDs by saving them.URI templates might be set in the links array in an annotation, for example:

links = {
"canonical" = "/node/{node}",
"edit-form" = "/node/{node}/edit",
"version-history" = "/node/{node}/revisions"
}

or specified in a callback function set like:

uri_callback = "comment_uri",

If the path is not set in the links array, the uri_callback function is used for setting the path. If this does not exist and the link relationship type is canonical, the path is set using the default template: entity/entityType/id.

Parameters
string$relThe link relationship type, for example: canonical or edit-form.
array$optionsSee ::generateFromRoute() for the available options.
Returns
The URL object.
Exceptions
\Drupal\Core\Entity\EntityMalformedException
\Drupal\Core\Entity\Exception\UndefinedLinkTemplateException
}

Implements EntityInterface.

trustData ( )

{Sets that the data should be trusted.If the data is trusted then dependencies will not be calculated on save and schema will not be used to cast the values. Generally this is only used during module and theme installation. Once the config entity has been saved the data will no longer be marked as trusted. This is an optimization for creation of configuration during installation.

Returns
$this
See Also
::createConfiguration()
}

Implements ConfigEntityInterface.

unsetThirdPartySetting (   $module,
  $key 
)

{Unsets a third-party setting.

Parameters
string$moduleThe module providing the third-party setting.
string$keyThe setting name.
Returns
mixed The value.
}

Implements ThirdPartySettingsInterface.

url (   $rel = 'edit-form',
  $options = array() 
)

{Gets the public URL for this entity.

Parameters
string$relThe link relationship type, for example: canonical or edit-form.
array$optionsSee ::generateFromRoute() for the available options.
Returns
string The URL for this entity.
Deprecated:
in Drupal 8.0.0, intended to be removed in Drupal 9.0.0 Please use toUrl() instead.
See Also
::toUrl
}

Implements EntityInterface.

Referenced by ConfigTestController\disable(), and ConfigTestController\enable().

Here is the caller graph for this function:

urlInfo (   $rel = 'edit-form',
array  $options = [] 
)

{Gets the URL object for the entity.

Parameters
string$relThe link relationship type, for example: canonical or edit-form.
array$optionsSee ::generateFromRoute() for the available options.
Returns
The URL object.
Deprecated:
in Drupal 8.0.0, intended to be removed in Drupal 9.0.0 Use ::toUrl() instead.
See Also
::toUrl
}

Implements EntityInterface.


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