class Action
Same name in this branch
- main core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
- main core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
- main core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
Same name and namespace in other branches
- 11.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
- 11.x core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
- 11.x core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
- 11.x core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
- 10 core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
- 10 core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
- 10 core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
- 10 core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
- 9 core/modules/action/src/Plugin/migrate/source/Action.php \Drupal\action\Plugin\migrate\source\Action
- 9 core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
- 9 core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
- 9 core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
- 8.9.x core/modules/action/src/Plugin/migrate/source/Action.php \Drupal\action\Plugin\migrate\source\Action
- 8.9.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
- 8.9.x core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
Defines the configured action entity.
Attributes
#[ConfigEntityType(id: 'action', label: new TranslatableMarkup('Action'), label_collection: new TranslatableMarkup('Actions'), label_singular: new TranslatableMarkup('action'), label_plural: new TranslatableMarkup('actions'), entity_keys: [
'id' => 'id',
'label' => 'label',
], admin_permission: 'administer actions', label_count: [
'singular' => '@count action',
'plural' => '@count actions',
], config_export: [
'id',
'label',
'type',
'plugin',
'configuration',
])]
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements \Drupal\Core\Entity\EntityInterface uses \Drupal\Core\Cache\RefinableCacheableDependencyTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements \Drupal\Core\Config\Entity\ConfigEntityInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Entity\SynchronizableEntityTrait extends \Drupal\Core\Entity\EntityBase
- class \Drupal\system\Entity\Action implements \Drupal\system\ActionConfigEntityInterface, \Drupal\Core\Entity\EntityWithPluginCollectionInterface extends \Drupal\Core\Config\Entity\ConfigEntityBase
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements \Drupal\Core\Config\Entity\ConfigEntityInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Entity\SynchronizableEntityTrait extends \Drupal\Core\Entity\EntityBase
Expanded class hierarchy of Action
15 files declare their use of Action
- ActionResourceTestBase.php in core/
modules/ system/ tests/ src/ Functional/ Rest/ ActionResourceTestBase.php - ActionTest.php in core/
modules/ jsonapi/ tests/ src/ Functional/ ActionTest.php - ActionTest.php in core/
modules/ system/ tests/ src/ Kernel/ Action/ ActionTest.php - ActionValidationTest.php in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ActionValidationTest.php - ConfigEntityImportTest.php in core/
modules/ system/ tests/ src/ Kernel/ Entity/ ConfigEntityImportTest.php
26 string references to 'Action'
- BulkForm::defineOptions in core/
modules/ views/ src/ Plugin/ views/ field/ BulkForm.php - Information about options for all kinds of purposes will be held here.
- BulkForm::viewsFormValidate in core/
modules/ views/ src/ Plugin/ views/ field/ BulkForm.php - BulkForm::__construct in core/
modules/ views/ src/ Plugin/ views/ field/ BulkForm.php - Constructs a new BulkForm object.
- BulkFormTest::testBulkForm in core/
modules/ views/ tests/ src/ Functional/ BulkFormTest.php - Tests the bulk form.
- BulkFormTest::testConfirmRouteWithParameters in core/
modules/ views/ tests/ src/ Functional/ BulkFormTest.php - Tests that route parameters are passed to the confirmation form route.
File
-
core/
modules/ system/ src/ Entity/ Action.php, line 19
Namespace
Drupal\system\EntityView source
class Action extends ConfigEntityBase implements ActionConfigEntityInterface, EntityWithPluginCollectionInterface {
/**
* The name (plugin ID) of the action.
*
* @var string
*/
protected $id;
/**
* The label of the action.
*
* @var string
*/
protected $label;
/**
* The action type.
*
* @var string|null
*/
protected $type = NULL;
/**
* The configuration of the action.
*
* @var array
*/
protected $configuration = [];
/**
* The plugin ID of the action.
*
* @var string
*/
protected $plugin;
/**
* The plugin collection that stores action plugins.
*
* @var \Drupal\Core\Action\ActionPluginCollection
*/
protected $pluginCollection;
/**
* {@inheritdoc}
*/
public static function create(array $values = []) {
// When no label is specified for this action config entity, default to the
// label of the used action plugin.
if (!array_key_exists('label', $values) && array_key_exists('plugin', $values)) {
try {
$action_plugin_manager = \Drupal::service('plugin.manager.action');
assert($action_plugin_manager instanceof PluginManagerInterface);
$action_plugin_definition = $action_plugin_manager->getDefinition($values['plugin']);
// @see \Drupal\Core\Annotation\Action::$label
assert(array_key_exists('label', $action_plugin_definition));
$values['label'] = $action_plugin_definition['label'];
} catch (PluginNotFoundException) {
}
}
return parent::create($values);
}
/**
* Encapsulates the creation of the action's LazyPluginCollection.
*
* @return \Drupal\Component\Plugin\LazyPluginCollection
* The action's plugin collection.
*/
protected function getPluginCollection() {
if (!$this->pluginCollection) {
$this->pluginCollection = new ActionPluginCollection(\Drupal::service('plugin.manager.action'), $this->plugin, $this->configuration);
}
return $this->pluginCollection;
}
/**
* {@inheritdoc}
*/
public function getPluginCollections() {
return [
'configuration' => $this->getPluginCollection(),
];
}
/**
* {@inheritdoc}
*/
public function getPlugin() {
return $this->getPluginCollection()
->get($this->plugin);
}
/**
* {@inheritdoc}
*/
public function setPlugin($plugin_id) {
$this->plugin = $plugin_id;
$this->getPluginCollection()
->addInstanceId($plugin_id);
}
/**
* {@inheritdoc}
*/
public function getPluginDefinition() {
return $this->getPlugin()
->getPluginDefinition();
}
/**
* {@inheritdoc}
*/
public function execute(array $entities) {
return $this->getPlugin()
->executeMultiple($entities);
}
/**
* {@inheritdoc}
*/
public function isConfigurable() {
return $this->getPlugin() instanceof ConfigurableInterface;
}
/**
* {@inheritdoc}
*/
public function getType() {
return $this->type;
}
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
/** @var \Drupal\system\ActionConfigEntityInterface $a */
/** @var \Drupal\system\ActionConfigEntityInterface $b */
$a_type = $a->getType();
$b_type = $b->getType();
if ($a_type != $b_type) {
return strnatcasecmp($a_type, $b_type);
}
return parent::sort($a, $b);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.