Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions bundle/Command/MigrateEzImageCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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');
Expand Down