[COMMAND] Change the way ListEventsCommand outputs the results to use the output interface and add some formatting

This commit is contained in:
Hugo Sales 2020-11-06 19:48:40 +00:00 committed by Hugo Sales
parent e8feb2ae84
commit 3301770642
Signed by untrusted user: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -67,6 +67,9 @@ EOF
); );
} }
/**
* Execute the command, outputing a list of GNU social events
*/
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$patterm = $input->getArgument('pattern') ?? 'GNUsocial.*'; $patterm = $input->getArgument('pattern') ?? 'GNUsocial.*';
@ -76,15 +79,16 @@ EOF
return preg_match('/' . $patterm . '/', $key); return preg_match('/' . $patterm . '/', $key);
}); });
echo "\n"; ksort($listeners);
foreach ($listeners as $event => $listener) { foreach ($listeners as $event => $listener) {
echo "Event '{$event}':\n"; $event = explode('.', $event)[1];
$output->writeln("<info>Event '<options=bold>{$event}</options=bold>':</info>");
foreach ($listener as $c) { foreach ($listener as $c) {
$r = new ReflectionFunction($c); $r = new ReflectionFunction($c);
$m = $r->getStaticVariables()['handler']; $m = $r->getStaticVariables()['handler'];
echo ' ' . get_class($m[0]) . '::' . $m[1] . "\n"; $output->writeln("\t" . get_class($m[0]) . '::' . $m[1]);
} }
echo "\n"; $output->writeln('');
} }
if (!$input->hasArgument('pattern')) { if (!$input->hasArgument('pattern')) {