blob: 157097f3f1540626d2472039a8756fd7d2a69c3d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\WebhookListeners\Command;
use OC\Core\Command\Base;
use OCA\WebhookListeners\Db\WebhookListener;
use OCA\WebhookListeners\Db\WebhookListenerMapper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ListWebhooks extends Base {
public function __construct(
private WebhookListenerMapper $mapper,
) {
parent::__construct();
}
protected function configure(): void {
parent::configure();
$this
->setName('webhook_listeners:list')
->setDescription('Lists configured webhook listeners');
}
protected function execute(InputInterface $input, OutputInterface $output): int {
$webhookListeners = array_map(
fn (WebhookListener $listener): array => array_map(
fn (string|array|null $value): ?string => (is_array($value) ? json_encode($value) : $value),
$listener->jsonSerialize()
),
$this->mapper->getAll()
);
$this->writeTableInOutputFormat($input, $output, $webhookListeners);
return static::SUCCESS;
}
}
|