Skip to content
Snippets Groups Projects

Resolve #3303127 "Add config actions"

Open Adam G-H requested to merge issue/drupal-3303127:3303127-add-config-actions into 11.x
Compare and
22 files
+ 640
61
Compare changes
  • Side-by-side
  • Inline
Files
22
@@ -5,7 +5,9 @@
@@ -5,7 +5,9 @@
namespace Drupal\Core\Config\Action\Attribute;
namespace Drupal\Core\Config\Action\Attribute;
// cspell:ignore inflector
// cspell:ignore inflector
 
use Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException;
use Drupal\Core\Config\Action\Exists;
use Drupal\Core\Config\Action\Exists;
 
use Drupal\Core\Extension\ExtensionDiscovery;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
/**
@@ -30,12 +32,23 @@ final class ActionMethod {
@@ -30,12 +32,23 @@ final class ActionMethod {
* ID. For example, if the method is called 'addArray' this can be set to
* ID. For example, if the method is called 'addArray' this can be set to
* 'addMultipleArrays'. Set to FALSE if a pluralized version does not make
* 'addMultipleArrays'. Set to FALSE if a pluralized version does not make
* logical sense.
* logical sense.
 
* @param string|null $name
 
* The name of the action, if it should differ from the method name. Will be
 
* pluralized if $pluralize is TRUE. Must follow the rules for a valid PHP
 
* function name (e.g., no spaces, no Unicode characters, etc.). If used,
 
* the actual name of the method will NOT be available as an action name.
 
*
 
* @see https://www.php.net/manual/en/functions.user-defined.php
*/
*/
public function __construct(
public function __construct(
public readonly Exists $exists = Exists::ErrorIfNotExists,
public readonly Exists $exists = Exists::ErrorIfNotExists,
public readonly TranslatableMarkup|string $adminLabel = '',
public readonly TranslatableMarkup|string $adminLabel = '',
public readonly bool|string $pluralize = TRUE,
public readonly bool|string $pluralize = TRUE,
 
public readonly ?string $name = NULL,
) {
) {
 
if ($name && !preg_match(ExtensionDiscovery::PHP_FUNCTION_PATTERN, $name)) {
 
throw new InvalidPluginDefinitionException('entity_method', sprintf("'%s' is not a valid PHP function name.", $name));
 
}
}
}
}
}
Loading