You are here

public function PurgerCommands::purgerList in Purge 8.3

List all configured purgers in order of execution.

@usage drush p:purger-ls List all configured purgers in order of execution. @usage drush p:purger-ls --format=list Retrieve a simple list of instance IDs. @usage drush p:purger-ls --format=json Export as JSON. @usage drush p:purger-ls --format=yaml Export as YAML.

@command p:purger-ls @aliases ppls,p-purger-ls @field-labels instance_id: Instance plugin_id: Plugin label: Label description: Description

Parameters

array $options: Associative array of options whose values come from Drush.

Return value

array|\Consolidation\OutputFormatters\StructuredData\RowsOfFields Row-based structure of data.

File

modules/purge_drush/src/Commands/PurgerCommands.php, line 107

Class

PurgerCommands
Configure Purge Purgers from the command line.

Namespace

Drupal\purge_drush\Commands

Code

public function purgerList(array $options = [
  'format' => 'table',
]) {
  $definitions = $this->purgePurgers
    ->getPlugins();
  $enabled = $this->purgePurgers
    ->getPluginsEnabled();
  $labels = $this->purgePurgers
    ->getLabels();
  $rows = [];
  if ($options['format'] == 'list') {
    foreach ($enabled as $instance_id => $plugin_id) {
      $rows[] = $instance_id;
    }
    return $rows;
  }
  else {
    foreach ($enabled as $instance_id => $plugin_id) {
      $rows[$instance_id] = [
        'instance_id' => $instance_id,
        'plugin_id' => $plugin_id,
        'label' => (string) $labels[$instance_id],
        'description' => (string) $definitions[$plugin_id]['description'],
      ];
    }
    return new RowsOfFields($rows);
  }
}