protected function execute(InputInterface $input, OutputInterface $output) { $this->configuration = $this->getHelperSet()->get('configuration')->getConfiguration(); $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager(); $this->questionHelper = $this->getHelperSet()->get('question'); if (!empty($this->configuration['assetsProcessing']['maxPixelSize']) && $this->configuration['assetsProcessing']['maxPixelSize'] > 0) { $this->downscaler = new DownscaleImageManager($this->entityManager, null, $this->configuration['assetsProcessing']['driver'], $this->configuration['assetsProcessing']['maxPixelSize']); $confirmation = new ConfirmationQuestion('<question>Are you sure to downscale all your image documents to ' . $this->configuration['assetsProcessing']['maxPixelSize'] . 'px?</question>', false); if ($this->questionHelper->ask($input, $output, $confirmation)) { $documents = $this->entityManager->getRepository('RZ\\Roadiz\\Core\\Entities\\Document')->findBy(['mimeType' => ['image/png', 'image/jpeg', 'image/gif', 'image/tiff'], 'raw' => false]); $progress = new ProgressBar($output, count($documents)); $progress->setFormat('verbose'); $progress->start(); foreach ($documents as $document) { $this->downscaler->processDocumentFromExistingRaw($document); $progress->advance(); } $progress->finish(); $text = PHP_EOL . '<info>Every documents have been downscaled, a raw version has been kept.</info>' . PHP_EOL; /* * Clear cache documents */ $assetsClearer = new AssetsClearer(); $assetsClearer->clear(); $text .= $assetsClearer->getOutput() . PHP_EOL; } } else { $text = '<info>Your configuration is not set for downscaling documents.</info>' . PHP_EOL; $text .= 'Add <info>assetsProcessing.maxPixelSize</info> parameter in your <info>config.yml</info> file.' . PHP_EOL; } $output->writeln($text); }
protected function execute(InputInterface $input, OutputInterface $output) { $text = ""; $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager(); $this->nsCacheHelper = $this->getHelperSet()->get('ns-cache'); $assetsClearer = new AssetsClearer(); $doctrineClearer = new DoctrineCacheClearer($this->entityManager); $routingClearer = new RoutingCacheClearer(); $templatesClearer = new TemplatesCacheClearer(); $translationsClearer = new TranslationsCacheClearer(); $configurationClearer = new ConfigurationCacheClearer(); $nodeSourcesUrlsClearer = new NodesSourcesUrlsCacheClearer($this->nsCacheHelper->getCacheProvider()); $clearers = [$configurationClearer, $assetsClearer, $doctrineClearer, $routingClearer, $templatesClearer, $translationsClearer, $nodeSourcesUrlsClearer]; if ($input->getOption('clear-all')) { foreach ($clearers as $clearer) { $clearer->clear(); $text .= $clearer->getOutput(); } $text .= '<info>All caches have been been purged…</info>' . PHP_EOL; } elseif ($input->getOption('clear-configuration')) { $configurationClearer->clear(); $text .= $configurationClearer->getOutput(); } elseif ($input->getOption('clear-doctrine')) { $doctrineClearer->clear(); $text .= $doctrineClearer->getOutput(); } elseif ($input->getOption('clear-routes')) { $routingClearer->clear(); $text .= $routingClearer->getOutput(); } elseif ($input->getOption('clear-assets')) { $assetsClearer->clear(); $text .= $assetsClearer->getOutput(); } elseif ($input->getOption('clear-templates')) { $templatesClearer->clear(); $text .= $templatesClearer->getOutput(); } elseif ($input->getOption('clear-translations')) { $translationsClearer->clear(); $text .= $translationsClearer->getOutput(); } elseif ($input->getOption('clear-nsurls')) { $nodeSourcesUrlsClearer->clear(); $text .= $nodeSourcesUrlsClearer->getOutput(); } else { $text .= $this->getInformations(); } $output->writeln($text); }