You are here

public function ConfigActionsService::listAll in Config Actions 8

Return a list of actions within a module

Parameters

string $module_name: If omitted, all actions are listed

string $file: if empty, list all actions files in the module. Otherwise only list actions in the named file. Just the file, not the path. Do not include the .yml extension.

Return value

array keyed by module name and action file name each element an action array keyed by action id $result[$module_name][$file_name][$action_id] = action_data

Overrides ConfigActionsServiceInterface::listAll

File

src/ConfigActionsService.php, line 380

Class

ConfigActionsService
Base class for config_actions plugins.

Namespace

Drupal\config_actions

Code

public function listAll($module_name = '', $file = '') {
  $result = [];
  $modules = !empty($module_name) ? [
    $module_name => [],
  ] : $this->moduleHandler
    ->getModuleList();
  foreach ($modules as $module_name => $extension) {
    $files = $this
      ->getConfigActionsFiles($module_name);
    foreach ($files as $action_file) {
      if (empty($file) || $file === $action_file['file']) {
        $actions = $this
          ->readActions($action_file['path']);
        $result[$module_name][$action_file['file']] = $this
          ->listActions($actions);
      }
    }
  }
  return $result;
}