52 lines
1.1 KiB
PHP
52 lines
1.1 KiB
PHP
|
<?php
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace OCA\Radio\Command;
|
||
|
|
||
|
use OCA\Radio\Service\SearchService;
|
||
|
use OCA\Mail\Service\CleanupService;
|
||
|
use Symfony\Component\Console\Command\Command;
|
||
|
use Symfony\Component\Console\Input\InputArgument;
|
||
|
use Symfony\Component\Console\Input\InputInterface;
|
||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||
|
|
||
|
class Search extends Command {
|
||
|
|
||
|
/** @var CleanupService */
|
||
|
private $cleanupService;
|
||
|
/**
|
||
|
* @var SearchService
|
||
|
*/
|
||
|
private $searchService;
|
||
|
|
||
|
public function __construct(SearchService $searchService) {
|
||
|
parent::__construct();
|
||
|
|
||
|
$this->searchService = $searchService;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return void
|
||
|
*/
|
||
|
protected function configure() {
|
||
|
$this->setName('radio:search');
|
||
|
$this->setDescription('Search for radio stations');
|
||
|
|
||
|
$this->addArgument("term", InputArgument::OPTIONAL);
|
||
|
}
|
||
|
|
||
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||
|
$radioStations = $this->searchService->findRadioStations(
|
||
|
$input->getArgument("term")
|
||
|
);
|
||
|
|
||
|
$output->writeln("Found radio stations");
|
||
|
foreach ($radioStations as $radioStation) {
|
||
|
$output->writeln("* $radioStation");
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
}
|