You are here

public function ConfigActionsPluginBase::execute in Config Actions 8

Execute the action for this plugin.

Parameters

array $action: a config_actions action:

Return value

mixed FALSE if there was a problem executing the plugin action

Overrides ConfigActionsPluginInterface::execute

1 method overrides ConfigActionsPluginBase::execute()
ConfigActionsInclude::execute in src/Plugin/ConfigActions/ConfigActionsInclude.php
Main execute to perform the include

File

src/ConfigActionsPluginBase.php, line 381

Class

ConfigActionsPluginBase
Base class for config_actions plugins.

Namespace

Drupal\config_actions

Code

public function execute(array $action) {

  // Load any specified config.
  if (!empty($this->template)) {

    // Grab additional variables from template name wildcards.
    $this->replace = array_merge($this->replace, ConfigActionsTransform::parseWildcards($this->template, $this->dest));

    // Override the source plugin type.
    if (is_array($this->source)) {
      $this->source[] = 'template::' . $this->template;
    }
    else {
      $this->source = $this->template;
      $this->source_type = 'template';
    }
  }
  $tree = $this->actionService
    ->loadSource($this->source, $this->source_type, $this->base);
  if (!is_array($tree)) {
    $tree = [];
  }
  if (in_array('load', $this->replace_in)) {
    $tree = $this
      ->replaceData($tree, $this->replace, 'load');
  }

  // Transform the source data and return new data.
  $tree = $this
    ->transform($tree);
  if (in_array('save', $this->replace_in)) {
    $tree = $this
      ->replaceData($tree, $this->replace, 'save');
  }

  // Save new data tree to destination.
  $this->actionService
    ->saveSource($tree, $this->dest, $this->dest_type, $this->base, is_array($this->source));
  return $tree;
}