You are here

class ConfigActionsDefault in Config Actions 8

Default Plugin for changing, adding, deleting data.

Plugin annotation


@ConfigActionsPlugin(
  id = "default",
  description = @Translation("Change, Add, Delete data."),
  options = {
    "path" = { },
    "value" = NULL,
    "change" = NULL,
    "add" = NULL,
    "delete" = NULL,
    "value_path" = { },
    "current_value" = NULL,
  },
  replace_in = { "path", "value", "change", "add", "delete", "value_path", "current_value", "dest", "load" },
)

Hierarchy

Expanded class hierarchy of ConfigActionsDefault

File

src/Plugin/ConfigActions/ConfigActionsDefault.php, line 27

Namespace

Drupal\config_actions\Plugin\ConfigActions
View source
class ConfigActionsDefault extends ConfigActionsPluginBase {
  use ConfigActionsValidateTrait;

  /**
   * Config data to be changed.
   * Deprecated in favor of $changed.
   *
   * @var mixed
   */
  protected $value;

  /**
   * Config data to be changed.
   * @var mixed
   */
  protected $change;

  /**
   * Config data to be added.
   * @var mixed
   */
  protected $add;

  /**
   * Config data to be deleted.
   * @var mixed
   */
  protected $delete;

  /**
   * Main transform to perform the change
   */
  public function transform(array $source) {
    $this
      ->validatePath($source);
    if (isset($this->value)) {
      $source = ConfigActionsTransform::change($source, $this->path, $this->value);
    }
    if (isset($this->change)) {
      $source = ConfigActionsTransform::change($source, $this->path, $this->change);
    }
    if (isset($this->add)) {
      $source = ConfigActionsTransform::add($source, $this->path, $this->add, TRUE);
    }
    if (isset($this->delete)) {
      $source = ConfigActionsTransform::delete($source, $this->path, $this->delete, TRUE);
    }
    return $source;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigActionsDefault::$add protected property Config data to be added.
ConfigActionsDefault::$change protected property Config data to be changed.
ConfigActionsDefault::$delete protected property Config data to be deleted.
ConfigActionsDefault::$value protected property Config data to be changed. Deprecated in favor of $changed.
ConfigActionsDefault::transform public function Main transform to perform the change Overrides ConfigActionsPluginBase::transform
ConfigActionsPluginBase::$actionService protected property
ConfigActionsPluginBase::$allowedOptions protected property The list of allowed option keys. Taken from the plugin annotation. key/value array where the key is the option name and the value is the default.
ConfigActionsPluginBase::$auto protected property If FALSE, do not run action when service has autoExecute enabled.
ConfigActionsPluginBase::$base protected property Optional Base path for source and dest.
ConfigActionsPluginBase::$config protected property Optional config corresponding to id.
ConfigActionsPluginBase::$dest protected property Optional destination id of config item.
ConfigActionsPluginBase::$dest_type protected property Plugin type of the destination.
ConfigActionsPluginBase::$did_replace protected property List to keep track of what options have had string replacement.
ConfigActionsPluginBase::$id protected property The id of the action.
ConfigActionsPluginBase::$key protected property The pattern of the action key (id).
ConfigActionsPluginBase::$module protected property Optional Module name for source templates. 1
ConfigActionsPluginBase::$pluginData protected property Optional data used by the plugins. Taken from the plugin annotation.
ConfigActionsPluginBase::$pluginId protected property The id name of the plugin instance. Overrides PluginBase::$pluginId
ConfigActionsPluginBase::$replace protected property List of string replacement variables and values.
ConfigActionsPluginBase::$replace_in protected property List of options that allow string replacement.
ConfigActionsPluginBase::$source protected property Source data to manipulate.
ConfigActionsPluginBase::$source_type protected property Plugin type of the source.
ConfigActionsPluginBase::$template protected property Overrides the Source with an existing config/templates template defined in some installed module. 1
ConfigActionsPluginBase::addAllowed protected function Add additional allowed options. Used by Traits in plugins to add global options.
ConfigActionsPluginBase::create public static function Create a plugin instance from the container Overrides ContainerFactoryPluginInterface::create
ConfigActionsPluginBase::execute public function Execute the action for this plugin. Overrides ConfigActionsPluginInterface::execute 1
ConfigActionsPluginBase::getData protected function Return a specific property from the plugin specific data.
ConfigActionsPluginBase::getOption public function Return a current option value.
ConfigActionsPluginBase::initPlugin protected function Initialize a plugin.
ConfigActionsPluginBase::isSequential protected function Return True if array is Sequential
ConfigActionsPluginBase::parseOptions public function Parse any property references in the options.
ConfigActionsPluginBase::replaceData protected function Perform string replacement on the $data and return the result.
ConfigActionsPluginBase::setOptions public function Process an Options array to set various internal variable defaults.
ConfigActionsPluginBase::__construct public function Constructs a new ConfigActionsPlugin object. Overrides PluginBase::__construct
ConfigActionsValidateTrait::$current_value protected property Current data at path to be validated.
ConfigActionsValidateTrait::$path protected property Path to config being altered
ConfigActionsValidateTrait::$value_path protected property Optional path to the $current_value to be used instead of $path.
ConfigActionsValidateTrait::validatePath protected function Perform validation of the path. Call this from the plugin transform or execute method. Throws exception if validation fails.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.