2020-08-29 23:39:35 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\News\Command\Config;
|
|
|
|
|
|
|
|
use OCA\News\Service\FeedServiceV2;
|
|
|
|
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 FeedDelete extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var FeedServiceV2 service for the feeds.
|
|
|
|
*/
|
|
|
|
protected $feedService;
|
|
|
|
|
|
|
|
public function __construct(FeedServiceV2 $feedService)
|
|
|
|
{
|
|
|
|
parent::__construct(null);
|
|
|
|
|
|
|
|
$this->feedService = $feedService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Configure command
|
2021-01-08 23:26:10 +01:00
|
|
|
*
|
|
|
|
* @return void
|
2020-08-29 23:39:35 +02:00
|
|
|
*/
|
|
|
|
protected function configure()
|
|
|
|
{
|
|
|
|
$this->setName('news:feed:delete')
|
|
|
|
->setDescription('Remove a feed')
|
2020-10-28 23:06:49 +01:00
|
|
|
->addArgument('user-id', InputArgument::REQUIRED, 'User to remove the feed from')
|
|
|
|
->addArgument('feed-id', InputArgument::REQUIRED, 'Feed ID', null);
|
2020-08-29 23:39:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute command
|
|
|
|
*
|
|
|
|
* @param InputInterface $input
|
|
|
|
* @param OutputInterface $output
|
|
|
|
*
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
|
|
|
{
|
2020-10-28 23:06:49 +01:00
|
|
|
$user = $input->getArgument('user-id');
|
2021-01-08 23:26:10 +01:00
|
|
|
$id = (int) $input->getArgument('feed-id');
|
2020-08-29 23:39:35 +02:00
|
|
|
|
|
|
|
$this->feedService->delete($user, $id);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|