| 1: | <?php |
| 2: | namespace TIC\MailBundle\Command; |
| 3: | |
| 4: | use TIC\CoreBundle\Base\TICCommand as BaseCommand; |
| 5: | |
| 6: | use Symfony\Component\Console\Input\InputOption; |
| 7: | use Symfony\Component\Console\Input\InputArgument; |
| 8: | use Symfony\Component\Console\Input\InputInterface; |
| 9: | use Symfony\Component\Console\Output\OutputInterface; |
| 10: | |
| 11: | |
| 12: | |
| 13: | |
| 14: | class TemplateExportCommand extends BaseCommand |
| 15: | { |
| 16: | use \TIC\DormBundle\Traits\ManagerTrait; |
| 17: | |
| 18: | |
| 19: | |
| 20: | |
| 21: | protected function configure(): void |
| 22: | { |
| 23: | parent::configure(); |
| 24: | $this |
| 25: | ->setDescription("Export de modèles pour les notifications envoyées par l'application.") |
| 26: | ->addArgument('ref', InputArgument::OPTIONAL, "Référence d'un modèle à exporter (tous par défaut)") |
| 27: | ; |
| 28: | } |
| 29: | |
| 30: | |
| 31: | |
| 32: | |
| 33: | protected function execute(InputInterface $input, OutputInterface $output): int |
| 34: | { |
| 35: | $ref = $input->getArgument('ref'); |
| 36: | |
| 37: | $locale = null; |
| 38: | $config = $this->params->get('tic_mail.config'); |
| 39: | $formats = $config['formats']; |
| 40: | |
| 41: | if (empty($ref)) { |
| 42: | foreach ($this->getRepo('Template')->listAll() as $item) |
| 43: | echo $item->exportMail($locale, $formats); |
| 44: | } else { |
| 45: | $item = $this->getRepo('Template')->find($ref); |
| 46: | if ($item) echo $item->exportMail($locale, $formats); |
| 47: | } |
| 48: | |
| 49: | return self::SUCCESS; |
| 50: | } |
| 51: | |
| 52: | } |
| 53: | |