function Action::create

Same name in other branches
  1. 11.x core/modules/system/src/Entity/Action.php \Drupal\system\Entity\Action::create()

Overrides EntityBase::create

17 calls to Action::create()
ActionResourceTestBase::createEntity in core/modules/system/tests/src/Functional/Rest/ActionResourceTestBase.php
Creates the entity to be tested.
ActionResourceTestBase::createEntity in core/modules/action/tests/src/Functional/Rest/ActionResourceTestBase.php
Creates the entity to be tested.
ActionTest::createEntity in core/modules/action/tests/src/Functional/Jsonapi/ActionTest.php
Creates the entity to be tested.
ActionTest::createEntity in core/modules/jsonapi/tests/src/Functional/ActionTest.php
Creates the entity to be tested.
ActionTest::testDependencies in core/modules/system/tests/src/Kernel/Action/ActionTest.php
Tests the dependency calculation of actions.

... See full list

File

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

Class

Action
Defines the configured action entity.

Namespace

Drupal\system\Entity

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.