public function WebhooksCommands::list in Webhooks 8
List webhooks.
@option type Filter by webhook type, e.g. incoming, outgoing. @option status Filter by status, e.g. 0, 1. @usage webhooks-list Usage description
@command webhooks:list @aliases wt @field-labels display_name: Name machine_name: Machine Name type: Type status: Status @default-fields display_name,machine_name,type,status @aliases pml,pm-list @filter-default-field display_name
Return value
\Consolidation\OutputFormatters\StructuredData\RowsOfFields The rows of fields object.
File
- src/
Commands/ WebhooksCommands.php, line 116
Class
- WebhooksCommands
- The webhooks Drush commandfile.
Namespace
Drupal\webhooks\CommandsCode
public function list($options = [
'type' => '',
'status' => NULL,
]) {
$query = $this->entityTypeManager
->getStorage('webhook_config')
->getQuery();
if (isset($options['status'])) {
$query
->condition('status', $options['status']);
}
if ($options['type']) {
$query
->condition('type', $options['type']);
}
$ids = $query
->execute();
$webhooks_configs = WebhookConfig::loadMultiple($ids);
/** @var \Drupal\webhooks\Entity\WebhookConfigInterface $webhooks_config */
foreach ($webhooks_configs as $webhooks_config) {
$rows[] = [
'display_name' => $webhooks_config
->label(),
'machine_name' => $webhooks_config
->id(),
'type' => $this
->t('@type', [
'@type' => $webhooks_config
->getType(),
]),
'status' => $webhooks_config
->status() ? $this
->t('active') : $this
->t('inactive'),
];
}
return new RowsOfFields((array) $rows);
}