synchronizer = $synchronizer;
$this->config = $config;
parent::__construct(self::NAME);
}
/**
* @inheritDoc
*/
protected function configure(): void
{
$this->setDescription('Synchronize media files with remote storage.');
}
/**
* Run synchronization.
*
* @param InputInterface $input
* @param OutputInterface $output
* @return int
* @throws LocalizedException
*/
public function execute(InputInterface $input, OutputInterface $output): int
{
if (!$this->config->isEnabled()) {
$output->writeln('Remote storage is not enabled.');
return Cli::RETURN_FAILURE;
}
$output->writeln('Uploading media files to remote storage.');
foreach ($this->synchronizer->execute() as $file) {
$output->writeln('- ' . $file);
}
$output->writeln('End of upload.');
return Cli::RETURN_SUCCESS;
}
}