1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-08 06:06:45 +02:00

feat(console): add EntriesHasCommand #543

This commit is contained in:
Awilum
2021-09-14 18:34:47 +03:00
parent 278793ab8f
commit e9462d15fc
2 changed files with 41 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/**
* Flextype (https://flextype.org)
* Founded by Sergey Romanenko and maintained by Flextype Community.
*/
namespace Flextype\Console\Commands\Entries;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
class EntriesHasCommand extends Command
{
protected function configure(): void
{
$this->setName('entries:has');
$this->setDescription('Check whether entry exists..');
$this->addOption('id', null, InputOption::VALUE_REQUIRED, 'Unique identifier of the entry.');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
if (entries()->has($input->getOption('id'))) {
$io->success('Entry ' . $input->getOption('id') . ' exists');
return Command::SUCCESS;
} else {
$io->error('Entry ' . $input->getOption('id') . ' ins\'t exists');
return Command::FAILURE;
}
}
}

View File

@@ -15,6 +15,7 @@ use Flextype\Console\Commands\Entries\EntriesUpdateCommand;
use Flextype\Console\Commands\Entries\EntriesDeleteCommand;
use Flextype\Console\Commands\Entries\EntriesCopyCommand;
use Flextype\Console\Commands\Entries\EntriesMoveCommand;
use Flextype\Console\Commands\Entries\EntriesHasCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -28,6 +29,7 @@ class FlextypeConsoleApplication extends ConsoleApplication
console()->add(new EntriesUpdateCommand());
console()->add(new EntriesCopyCommand());
console()->add(new EntriesMoveCommand());
console()->add(new EntriesHasCommand());
parent::run();
}