diff --git a/bundle/Command/MigrateEzImageCommand.php b/bundle/Command/MigrateEzImageCommand.php index d2c3dbf9..33795d53 100644 --- a/bundle/Command/MigrateEzImageCommand.php +++ b/bundle/Command/MigrateEzImageCommand.php @@ -13,6 +13,7 @@ use Symfony\Component\Console\Helper\Table; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Question\Question; @@ -57,6 +58,11 @@ protected function configure() $this ->setName('netgen:ngremotemedia:migrate:ezimage') ->setDescription('This command will migrate ezimage field to ngremotemedia field.') + ->addArgument( + 'migrate-field', + InputArgument::IS_ARRAY, + "Migrate one field: content type identifier, image field type identifier, remote media type identifier" + ) ->addOption( 'dry-run', 'd', @@ -255,12 +261,28 @@ protected function execute(InputInterface $input, OutputInterface $output) $dryRun = $input->getOption('dry-run'); $continueOnError = $input->getOption('continue-on-error'); - $this->listFields(); - $output->writeln(''); + $migrateField = $input->getArgument('migrate-field'); + if (count($migrateField) == 3) { + $contentType = $this->contentTypeService->loadContentTypeByIdentifier($migrateField[0]); + + $ezimageFieldIdentifier = $migrateField[1]; + if (!$contentType->getFieldDefinition($ezimageFieldIdentifier)) { + throw new \InvalidArgumentException('Could not find the field with the identifier:'. $ezimageFieldIdentifier); + } + $remoteMediaFieldIdentifier = $migrateField[2]; + if (!$contentType->getFieldDefinition($remoteMediaFieldIdentifier)) { + throw new \InvalidArgumentException('Could not find the field with the identifier:'. $remoteMediaFieldIdentifier); + } + + } else { + $this->listFields(); + $output->writeln(''); + + $contentType = $this->getContentType(); + $ezimageFieldIdentifier = $this->getFieldIdentifier($contentType, 'source'); + $remoteMediaFieldIdentifier = $this->getFieldIdentifier($contentType, 'destination'); + } - $contentType = $this->getContentType(); - $ezimageFieldIdentifier = $this->getFieldIdentifier($contentType, 'source'); - $remoteMediaFieldIdentifier = $this->getFieldIdentifier($contentType, 'destination'); $overwrite = $this->getOverwrite(); $siteaccess = $this->getContainer()->get('ezpublish.siteaccess');