Action
class Action extends ConfigEntityBase implements ActionConfigEntityInterface, EntityWithPluginCollectionInterface (View source)
Defines the configured action entity.
Traits
Provides a trait for calculating the dependencies of a plugin.
Provides a trait for accessing synchronization information.
Provides a trait for managing an object's dependencies.
Trait for \Drupal\Core\Cache\RefinableCacheableDependencyInterface.
Provides dependency injection friendly methods for serialization.
Trait for \Drupal\Core\Cache\CacheableDependencyInterface.
Properties
| protected string[] | $cacheContexts | Cache contexts. |
from CacheableDependencyTrait |
| protected string[] | $cacheTags | Cache tags. |
from CacheableDependencyTrait |
| protected int | $cacheMaxAge | Cache max-age. |
from CacheableDependencyTrait |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected string | $entityTypeId | The entity type. |
from EntityBase |
| protected bool | $enforceIsNew | Boolean indicating whether the entity should be forced to be new. |
from EntityBase |
| protected ComplexDataInterface | $typedData | A typed data object wrapping this entity. |
from EntityBase |
| protected array | $dependencies | The object's dependencies. |
from DependencyTrait |
| protected bool | $isSyncing | Whether this entity is being created, updated or deleted through a synchronization process. |
from SynchronizableEntityTrait |
| protected string | $originalId | The original ID of the configuration entity. |
from ConfigEntityBase |
| protected bool | $status | The enabled/disabled status of the configuration entity. |
from ConfigEntityBase |
| protected string | $uuid | The UUID for this entity. |
from ConfigEntityBase |
| protected string | $langcode | The language code of the entity's default language. |
from ConfigEntityBase |
| protected array | $third_party_settings | Third party entity settings. |
from ConfigEntityBase |
| protected array | $_core | Information maintained by Drupal core about configuration. |
from ConfigEntityBase |
| protected bool | $trustedData | Trust supplied data and not use configuration schema on save. |
from ConfigEntityBase |
| protected string | $id | The name (plugin ID) of the action. |
|
| protected string | $label | The label of the action. |
|
| protected string | $type | The action type. |
|
| protected array | $configuration | The configuration of the action. |
|
| protected string | $plugin | The plugin ID of the action. |
|
| protected ActionPluginCollection | $pluginCollection | The plugin collection that stores action plugins. |
Methods
Sets cacheability; useful for value object constructors.
Gets the entity type bundle info service.
Gets the URL object for the entity.
Generates the HTML for a link to this entity.
Gets an array of placeholders for this entity.
Gets a list of URI relationships supported by this entity.
Checks data value access.
Acts on a saved entity before the insert or update hook is invoked.
Changes the values of an entity before it is created.
Acts on entities before they are deleted and before hooks are invoked.
Acts on deleted entities before the delete hook is invoked.
Gets a list of entities referenced by this entity.
The list cache tags to invalidate for this entity.
Returns the cache tags that should be used to invalidate caches.
Loads one or more entities.
Constructs a new entity object, without permanently saving it.
Invalidates an entity's cache tags upon save.
Invalidates an entity's cache tags upon delete.
Gets a typed data object for this entity object.
Gets the key that is used to store configuration dependencies.
Gets the configuration target identifier for the entity.
Calculates and returns dependencies of a specific plugin instance.
Calculates and adds dependencies of a specific plugin instance.
Returns whether this entity is being changed during the uninstall process.
Helper callback for uasort() to sort configuration entities by weight and label.
Calculates dependencies and stores them in the dependency property.
Informs the entity that entities it depends on will be deleted.
Sets the value of a third-party setting.
Gets the value of a third-party setting.
Gets all third-party settings of a given module.
Unsets a third-party setting.
Gets the list of third parties that store information.
Encapsulates the creation of the action's LazyPluginCollection.
Gets the plugin collections used by this object.
Returns the operation plugin.
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Returns whether or not this action is configurable.
Returns the operation type.
Details
protected $this
setCacheability(CacheableDependencyInterface $cacheability)
Sets cacheability; useful for value object constructors.
getCacheTags()
{@inheritdoc}
getCacheContexts()
{@inheritdoc}
getCacheMaxAge()
{@inheritdoc}
addCacheableDependency($other_object)
{@inheritdoc}
addCacheContexts(array $cache_contexts)
{@inheritdoc}
addCacheTags(array $cache_tags)
{@inheritdoc}
mergeCacheMaxAge($max_age)
{@inheritdoc}
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
__construct(array $values, string $entity_type)
Constructs an Entity object.
protected EntityTypeManagerInterface
entityTypeManager()
Gets the entity type manager.
protected EntityTypeBundleInfoInterface
entityTypeBundleInfo()
Gets the entity type bundle info service.
protected LanguageManagerInterface
languageManager()
Gets the language manager.
protected UuidInterface
uuidGenerator()
Gets the UUID generator.
string|int|null
id()
Gets the identifier.
string|null
uuid()
Gets the entity UUID (Universally Unique Identifier).
The UUID is guaranteed to be unique and can be used to identify an entity across multiple systems.
bool
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.
$this
enforceIsNew(bool $value = TRUE)
Enforces an entity to be new.
Allows migrations to create entities with pre-defined IDs by forcing the entity to be new before saving.
string
getEntityTypeId()
Gets the ID of the type of the entity.
string
bundle()
Gets the bundle of the entity.
string|TranslatableMarkup|null
label()
Gets the label of the entity.
Url
toUrl(string $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:
bool
hasLinkTemplate($rel)
Indicates if a link template exists for a given key.
protected array
linkTemplates()
Gets an array link templates.
Link
toLink(string|null $text = NULL, string $rel = 'canonical', array $options = [])
Generates the HTML for a link to this entity.
protected array
urlRouteParameters(string $rel)
Gets an array of placeholders for this entity.
Individual entity classes may override this method to add additional placeholders if desired. If so, they should be sure to replicate the property caching logic.
string[]
uriRelationships()
Gets a list of URI relationships supported by this entity.
bool|AccessResultInterface
access(string $operation, AccountInterface $account = NULL, bool $return_as_object = FALSE)
Checks data value access.
LanguageInterface
language()
Gets the language of the entity.
int
save()
Saves an entity permanently.
When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.
delete()
Deletes an entity permanently.
EntityInterface
createDuplicate()
Creates a duplicate of the entity.
EntityTypeInterface
getEntityType()
Gets the entity type definition.
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.
postSave(EntityStorageInterface $storage, bool $update = TRUE)
Acts on a saved entity before the insert or update hook is invoked.
Used after the entity is saved, but before invoking the insert or update 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.
static
preCreate(EntityStorageInterface $storage, array $values)
Changes the values of an entity before it is created.
Load defaults for example.
postCreate(EntityStorageInterface $storage)
Acts on a created entity before hooks are invoked.
Used after the entity is created, but before saving the entity and before any of the presave hooks are invoked.
See the @link entity_crud Entity CRUD topic @endlink for more information.
static
preDelete(EntityStorageInterface $storage, array $entities)
Acts on entities before they are deleted and before hooks are invoked.
Used before the entities are deleted and before invoking the delete hook.
static
postDelete(EntityStorageInterface $storage, array $entities)
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
static
postLoad(EntityStorageInterface $storage, array $entities)
Acts on loaded entities.
EntityInterface[]
referencedEntities()
Gets a list of entities referenced by this entity.
protected string[]
getListCacheTagsToInvalidate()
The list cache tags to invalidate for this entity.
string[]
getCacheTagsToInvalidate()
Returns the cache tags that should be used to invalidate caches.
This will not return additional cache tags added through addCacheTags().
static EntityInterface|null
load(mixed $id)
Loads an entity.
static EntityInterface[]
loadMultiple(array $ids = NULL)
Loads one or more entities.
static EntityInterface
create(array $values = [])
Constructs a new entity object, without permanently saving it.
protected
invalidateTagsOnSave(bool $update)
Invalidates an entity's cache tags upon save.
static protected
invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities)
Invalidates an entity's cache tags upon delete.
int|string|null
getOriginalId()
Gets the original ID.
$this
setOriginalId(int|string|null $id)
Sets the original ID.
array
toArray()
Gets an array of all property values.
ComplexDataInterface
getTypedData()
Gets a typed data object for this entity object.
The returned typed data object wraps this entity and allows dealing with entities based on the generic typed data API.
string
getConfigDependencyKey()
Gets the key that is used to store configuration dependencies.
string
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.
string
getConfigTarget()
Gets the configuration target identifier for the entity.
Used to supply the correct format for storing a reference targeting this entity in configuration.
protected $this
addDependency(string $type, string $name)
Adds a dependency.
protected
addDependencies(array $dependencies)
Adds multiple dependencies.
protected array
getPluginDependencies(PluginInspectionInterface $instance)
Calculates and returns dependencies of a specific plugin instance.
Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.
protected
calculatePluginDependencies(PluginInspectionInterface $instance)
Calculates and adds dependencies of a specific plugin instance.
Dependencies are added for the module that provides the plugin, as well as any dependencies declared by the instance's calculateDependencies() method, if it implements \Drupal\Component\Plugin\DependentPluginInterface.
protected ModuleHandlerInterface
moduleHandler()
Wraps the module handler.
protected ThemeHandlerInterface
themeHandler()
Wraps the theme handler.
setSyncing($syncing)
{@inheritdoc}
isSyncing()
{@inheritdoc}
mixed
get(string $property_name)
Returns the value of a property.
$this
set(string $property_name, mixed $value)
Sets the value of a property.
$this
enable()
Enables the configuration entity.
$this
disable()
Disables the configuration entity.
$this
setStatus(bool $status)
Sets the status of the configuration entity.
bool
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.
setUninstalling($uninstalling)
{@inheritdoc}
bool
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, \Drupal\language\Entity\ConfigurableLanguage::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.
static
sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
Helper callback for uasort() to sort configuration entities by weight and label.
protected TypedConfigManagerInterface
getTypedConfig()
Gets the typed config manager.
$this
calculateDependencies()
Calculates dependencies and stores them in the dependency property.
array
getDependencies()
Gets the configuration dependencies.
bool
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.
$this
setThirdPartySetting(string $module, string $key, mixed $value)
Sets the value of a third-party setting.
mixed
getThirdPartySetting(string $module, string $key, mixed $default = NULL)
Gets the value of a third-party setting.
array
getThirdPartySettings(string $module)
Gets all third-party settings of a given module.
mixed
unsetThirdPartySetting(string $module, string $key)
Unsets a third-party setting.
array
getThirdPartyProviders()
Gets the list of third parties that store information.
static protected ConfigManager
getConfigManager()
Gets the configuration manager.
bool
isInstallable()
Checks whether this entity is installable.
For example, a default view might not be installable if the base table doesn't exist.
$this
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.
bool
hasTrustedData()
Gets whether on not the data is trusted.
protected LazyPluginCollection
getPluginCollection()
Encapsulates the creation of the action's LazyPluginCollection.
LazyPluginCollection[]
getPluginCollections()
Gets the plugin collections used by this object.
ActionInterface
getPlugin()
Returns the operation plugin.
setPlugin($plugin_id)
{@inheritdoc}
getPluginDefinition()
{@inheritdoc}
execute(array $entities)
{@inheritdoc}
bool
isConfigurable()
Returns whether or not this action is configurable.
string
getType()
Returns the operation type.