diff --git a/src/flextype/core/Console/Commands/Entries/EntrieMoveCommand.php b/src/flextype/core/Console/Commands/Entries/EntrieMoveCommand.php new file mode 100644 index 00000000..b11db75c --- /dev/null +++ b/src/flextype/core/Console/Commands/Entries/EntrieMoveCommand.php @@ -0,0 +1,40 @@ +setName('entries:move'); + $this->setDescription('Move entry.'); + $this->addOption('id', null, InputOption::VALUE_REQUIRED, 'Unique identifier of the entry.'); + $this->addOption('newID', null, InputOption::VALUE_REQUIRED, 'New Unique identifier of the entry'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + $io = new SymfonyStyle($input, $output); + + if (entries()->move($input->getOption('id'), $input->getOption('newID'))) { + $io->success('Entry ' . $input->getOption('id') . ' moved to ' . $input->getOption('newID')); + return Command::SUCCESS; + } else { + $io->error('Entry ' . $input->getOption('id') . ' wasn\'t moved to ' . $input->getOption('newID')); + 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 773f426e..e0cb1a1e 100644 --- a/src/flextype/core/Console/FlextypeConsoleApplication.php +++ b/src/flextype/core/Console/FlextypeConsoleApplication.php @@ -14,6 +14,7 @@ use Flextype\Console\Commands\Entries\EntriesCreateCommand; 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 Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -26,6 +27,7 @@ class FlextypeConsoleApplication extends ConsoleApplication console()->add(new EntriesDeleteCommand()); console()->add(new EntriesUpdateCommand()); console()->add(new EntriesCopyCommand()); + console()->add(new EntriesMoveCommand()); parent::run(); }