You are here

protected function ConfigActionsService::getConfigActionsFiles in Config Actions 8

Return a list of action files for the specified module

Parameters

string $module_name:

Return value

array of config action files 'module': name of module 'file': simple name of action file 'path': full path to action file

2 calls to ConfigActionsService::getConfigActionsFiles()
ConfigActionsService::importAction in src/ConfigActionsService.php
Process a specific action id from a given module
ConfigActionsService::listAll in src/ConfigActionsService.php
Return a list of actions within a module

File

src/ConfigActionsService.php, line 99

Class

ConfigActionsService
Base class for config_actions plugins.

Namespace

Drupal\config_actions

Code

protected function getConfigActionsFiles($module_name = '') {
  $result = [];
  $modules = empty($module_name) ? $modules = $this->moduleHandler
    ->getModuleList() : [
    $module_name => $this->moduleHandler
      ->getModule($module_name),
  ];
  foreach ($modules as $module_name => $module) {
    $module_path = $module
      ->getPath();

    // Check to see if module has a config/actions folder.
    $path = $module_path . '/' . static::CONFIG_ACTIONS_CONFIG_DIR;
    if (is_dir($path)) {
      $action_storage = new FileStorage($path, StorageInterface::DEFAULT_COLLECTION);
      $files = $action_storage
        ->listAll();
      foreach ($files as $file) {
        $result[] = [
          'module' => $module_name,
          'file' => $file,
          'path' => $path . '/' . $file . '.yml',
        ];
      }
    }
  }
  return $result;
}