You are here

public function ConfigActionsCommands::actionsRun in Config Actions 8

Execute actions within a module.

@command config:actions-run @aliases car,config-actions-run

Parameters

$module_name: Name of module containing the action. If omitted, all actions in all modules are executed.

$file: Optional name of file within module containing action. If omitted, all actions in the module are executed.

$action_id: Optional name of action to execute. If omitted, all actions in the file are executed.

File

src/Commands/ConfigActionsCommands.php, line 83

Class

ConfigActionsCommands
A Drush commandfile.

Namespace

Drupal\config_actions\Commands

Code

public function actionsRun($module_name = '', $file = '', $action_id = '') {
  $result = $this->configActions
    ->importAction($module_name, $action_id, $file);
  if (empty($result)) {
    $this
      ->output()
      ->writeln(dt('No actions were executed.'));
  }
  else {
    foreach ($result as $source => $config) {
      if (is_null($config)) {
        $this
          ->output()
          ->writeln(dt('  Action: @action - SKIPPED', array(
          '@action' => $source,
        )));
      }
      else {
        $this
          ->output()
          ->writeln(dt('  Action: @action', array(
          '@action' => $source,
        )));
      }
    }
  }
}