You are here

class ConfigActionsInclude in Config Actions 8

Plugin for including an action from another module.

Plugin annotation


@ConfigActionsPlugin(
  id = "include",
  description = @Translation("Include action."),
  options = {
    "module" = "",
    "file" = "",
    "action" = "",
    "template" = "",
  }
)

Hierarchy

Expanded class hierarchy of ConfigActionsInclude

File

src/Plugin/ConfigActions/ConfigActionsInclude.php, line 22

Namespace

Drupal\config_actions\Plugin\ConfigActions
View source
class ConfigActionsInclude extends ConfigActionsPluginBase {

  /**
   * Name of module containing action.
   * @var string
   */
  protected $module;

  /**
   * Optional Name of file to include.
   * @var string
   */
  protected $file;

  /**
   * Optional Name of action to include.
   * @var string
   */
  protected $action;

  /**
   * The template file to be loaded from the master config/templates list.
   * @var
   */
  protected $template;

  /**
   * Remove plugin-specific options to just leave those to override import.
   * @param $action
   */
  protected function cleanAction($action) {
    unset($action['plugin']);
    unset($action['module']);
    unset($action['file']);
    unset($action['action']);

    // Ensure included actions get executed.
    $action['auto'] = TRUE;
    return $action;
  }

  /**
   * Main execute to perform the include
   */
  public function execute(array $action) {
    if (isset($this->replace)) {
      $action['replace'] = NestedArray::mergeDeepArray([
        $this->replace,
        isset($action['replace']) ? $action['replace'] : [],
      ], TRUE);
    }
    $action = $this
      ->cleanAction($action);
    return $this->actionService
      ->importAction($this->module, $this->action, $this->file, $action);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigActionsInclude::$action protected property Optional Name of action to include.
ConfigActionsInclude::$file protected property Optional Name of file to include.
ConfigActionsInclude::$module protected property Name of module containing action. Overrides ConfigActionsPluginBase::$module
ConfigActionsInclude::$template protected property The template file to be loaded from the master config/templates list. @var Overrides ConfigActionsPluginBase::$template
ConfigActionsInclude::cleanAction protected function Remove plugin-specific options to just leave those to override import.
ConfigActionsInclude::execute public function Main execute to perform the include Overrides ConfigActionsPluginBase::execute
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::$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::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::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::transform public function Return a transformed version of the source config tree. Overrides ConfigActionsPluginInterface::transform 4
ConfigActionsPluginBase::__construct public function Constructs a new ConfigActionsPlugin object. Overrides PluginBase::__construct
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.