Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Action.php

function Action::create

Overrides EntityBase::create

1 call to Action::create()
UserHooks::userRoleInsert in core/modules/user/src/Hook/UserHooks.php
Implements hook_ENTITY_TYPE_insert() for user_role entities.

File

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

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);
}
RSS feed
Powered by Drupal