diff --git a/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php b/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php new file mode 100644 index 00000000..a688fa4b --- /dev/null +++ b/src/flextype/core/Console/Commands/Entries/EntrieHasCommand.php @@ -0,0 +1,39 @@ +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; + } + } +} \ No newline at end of file diff --git a/src/flextype/core/Console/FlextypeConsoleApplication.php b/src/flextype/core/Console/FlextypeConsoleApplication.php index e0cb1a1e..760f0be7 100644 --- a/src/flextype/core/Console/FlextypeConsoleApplication.php +++ b/src/flextype/core/Console/FlextypeConsoleApplication.php @@ -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(); }