|
16 | 16 | use Symfony\Component\Console\Input\InputInterface; |
17 | 17 | use Symfony\Component\Console\Output\OutputInterface; |
18 | 18 | use Translation\Bundle\Service\StorageManager; |
| 19 | +use Translation\Bundle\Service\StorageService; |
19 | 20 |
|
20 | 21 | /** |
21 | 22 | * @author Tobias Nyholm <tobias.nyholm@gmail.com> |
@@ -44,12 +45,28 @@ protected function configure() |
44 | 45 | $this |
45 | 46 | ->setName(self::$defaultName) |
46 | 47 | ->setDescription('Sync the translations with the remote storage') |
47 | | - ->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default'); |
| 48 | + ->addArgument('configuration', InputArgument::OPTIONAL, 'The configuration to use', 'default') |
| 49 | + ->addArgument('direction', InputArgument::OPTIONAL, 'Use "down" if local changes should be overwritten', 'down'); |
48 | 50 | } |
49 | 51 |
|
50 | 52 | protected function execute(InputInterface $input, OutputInterface $output) |
51 | 53 | { |
| 54 | + switch ($input->getArgument('direction')) { |
| 55 | + case 'down': |
| 56 | + $direction = StorageService::DIRECTION_DOWN; |
| 57 | + |
| 58 | + break; |
| 59 | + case 'up': |
| 60 | + $direction = StorageService::DIRECTION_UP; |
| 61 | + |
| 62 | + break; |
| 63 | + default: |
| 64 | + $output->writeln(sprintf('Direction must be eitehr "up" or "down". Not "%s".', $input->getArgument('direction'))); |
| 65 | + |
| 66 | + return; |
| 67 | + } |
| 68 | + |
52 | 69 | $configName = $input->getArgument('configuration'); |
53 | | - $this->storageManager->getStorage($configName)->sync(); |
| 70 | + $this->storageManager->getStorage($configName)->sync($direction); |
54 | 71 | } |
55 | 72 | } |
0 commit comments