class Action

Same name in this branch
  1. 9 core/modules/action/src/Plugin/migrate/source/Action.php \Drupal\action\Plugin\migrate\source\Action
  2. 9 core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
  3. 9 core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
Same name and namespace in other branches
  1. 11.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
  2. 11.x core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
  3. 11.x core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
  4. 11.x core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
  5. 10 core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
  6. 10 core/modules/system/src/Plugin/migrate/source/Action.php \Drupal\system\Plugin\migrate\source\Action
  7. 10 core/lib/Drupal/Core/Action/Attribute/Action.php \Drupal\Core\Action\Attribute\Action
  8. 10 core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action
  9. 8.9.x core/modules/action/src/Plugin/migrate/source/Action.php \Drupal\action\Plugin\migrate\source\Action
  10. 8.9.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action
  11. 8.9.x core/lib/Drupal/Core/Annotation/Action.php \Drupal\Core\Annotation\Action

Defines the configured action entity.

Plugin annotation


@ConfigEntityType(
  id = "action",
  label = @Translation("Action"),
  label_collection = @Translation("Actions"),
  label_singular = @Translation("action"),
  label_plural = @Translation("actions"),
  label_count = @PluralTranslation(
    singular = "@count action",
    plural = "@count actions",
  ),
  admin_permission = "administer actions",
  entity_keys = {
    "id" = "id",
    "label" = "label"
  },
  config_export = {
    "id",
    "label",
    "type",
    "plugin",
    "configuration",
  }
)

Hierarchy

Expanded class hierarchy of Action

16 files declare their use of Action
ActionFormAjaxTest.php in core/modules/action/tests/src/FunctionalJavascript/ActionFormAjaxTest.php
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
CommentActionsTest.php in core/modules/comment/tests/src/Kernel/CommentActionsTest.php

... See full list

33 string references to 'Action'
action.routing.yml in core/modules/action/action.routing.yml
core/modules/action/action.routing.yml
ActionAdminManageForm::buildForm in core/modules/action/src/Form/ActionAdminManageForm.php
ActionAdminManageForm::submitForm in core/modules/action/src/Form/ActionAdminManageForm.php
ActionFormBase::create in core/modules/action/src/Form/ActionFormBase.php
ActionListTest::testEmptyActionList in core/modules/action/tests/src/Functional/ActionListTest.php
Tests the behavior when there are no actions to list in the admin page.

... See full list

File

core/modules/system/src/Entity/Action.php, line 39

Namespace

Drupal\system\Entity
View 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
   */
  protected $type;
  
  /**
   * 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;
  
  /**
   * 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 PluginHelper::isConfigurable($this->getPlugin());
  }
  
  /**
   * {@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.