You are here

function _ctools_drush_export_module_filter in Chaos Tool Suite (ctools) 7

Filter a nested array of exportables by export module.

Parameters

array $exportables: Passed by reference. A nested array of exportables, keyed by table name.

string $export_module: The name of the export module providing the exportable.

2 calls to _ctools_drush_export_module_filter()
ctools_drush_export_info in drush/ctools.drush.inc
Drush callback: Export info.
_ctools_drush_export_op_command_logic in drush/ctools.drush.inc
Helper function to abstract logic for selecting exportable types/objects from individual commands as they will all share this same error handling/arguments for returning list of exportables.

File

drush/ctools.drush.inc, line 735
CTools Drush commands.

Code

function _ctools_drush_export_module_filter($exportables, $export_module) {
  $module_list = module_list();
  if (!isset($module_list[$export_module])) {
    drush_log(dt('Invalid export module: !export_module', array(
      '!export_module' => $export_module,
    )), 'error');
  }
  foreach ($exportables as $table => $objects) {
    foreach ($objects as $key => $object) {
      if (empty($object->export_module) || $object->export_module !== $export_module) {
        unset($exportables[$table][$key]);
      }
    }
  }
  return array_filter($exportables);
}