Commit 7994d53a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3284025 by alexpott, nedjo, bircher: Add configuration actions API

parent 4d212d10
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -11,8 +11,8 @@ workflow:
variables:
  PHP_VERSION: "8.1"
  # @TODO unit testing...
  TEST_DIRECTORIES: "core/tests/Drupal/KernelTests/Core/Recipe core/tests/Drupal/FunctionalTests/Core/Recipe"
  CODE_DIRECTORIES: "core/lib/Drupal/Core/Recipe/"
  TEST_DIRECTORIES: "core/tests/Drupal/KernelTests/Core/Recipe core/tests/Drupal/FunctionalTests/Core/Recipe core/tests/Drupal/KernelTests/Core/Config/Action"
  CODE_DIRECTORIES: "core/lib/Drupal/Core/Recipe core/lib/Drupal/Core/Config/Action"

default:
  image: skpr/php-circleci:${PHP_VERSION}-v2-latest
+3 −0
Original line number Diff line number Diff line
@@ -50,6 +50,9 @@ parameters:
    supportsCredentials: false
  tempstore.expire: 604800
services:
  plugin.manager.config_action:
    class: Drupal\Core\Config\Action\ConfigActionManager
    parent: default_plugin_manager
  # Simple cache contexts, directly derived from the request context.
  cache_context.ip:
    class: Drupal\Core\Cache\Context\IpCacheContext
+32 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Core\Config\Action\Annotation;

use Drupal\Component\Annotation\Plugin;

/**
 * Defines a ConfigAction annotation object.
 *
 * @ingroup config_action_api
 *
 * @Annotation
 */
class ConfigAction extends Plugin {

  /**
   * The plugin ID.
   *
   * @var string
   */
  public $id;

  /**
   * The administrative label of the config action.
   *
   * @var \Drupal\Core\Annotation\Translation|string
   *
   * @ingroup plugin_translatable
   */
  public $admin_label = '';

}
+24 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Core\Config\Action\Attribute;

use Drupal\Core\Config\Action\Exists;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * @internal
 *   This API is experimental.
 */
#[\Attribute(\Attribute::TARGET_METHOD)]
final class ActionMethod {

  /**
   * @param \Drupal\Core\Config\Action\Exists $exists
   *   Determines behavior of action depending on entity existence.
   * @param \Drupal\Core\StringTranslation\TranslatableMarkup|string $adminLabel
   *   The admin label for the user interface.
   */
  public function __construct(public readonly Exists $exists = Exists::ERROR_IF_NOT_EXISTS, public readonly TranslatableMarkup|string $adminLabel = '') {
  }

}
+10 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\Core\Config\Action;

/**
 * @internal
 *   This API is experimental.
 */
final class ConfigActionException extends \RuntimeException {
}
Loading