| @@ 14-58 (lines=45) @@ | ||
| 11 | * Class CleanCommand |
|
| 12 | * @package Magestead\Command\Cache |
|
| 13 | */ |
|
| 14 | class CleanCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("cache:clean"); |
|
| 23 | $this->setDescription("Cleans cache types"); |
|
| 24 | $this->addArgument('type', InputArgument::OPTIONAL, '[cache code/type]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $output->writeln('<info>Cleaning all cache types</info>'); |
|
| 35 | ||
| 36 | $cacheType = $input->getArgument('type'); |
|
| 37 | $command = $this->getCommand(new Config($output), $cacheType); |
|
| 38 | $pCommand = "vagrant ssh -c '". $command ."'"; |
|
| 39 | return new ProcessCommand($pCommand, $this->_projectPath, $output); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @param Config $config |
|
| 44 | * @return bool|string |
|
| 45 | */ |
|
| 46 | protected function getCommand(Config $config, $cacheType) |
|
| 47 | { |
|
| 48 | $type = $config->type; |
|
| 49 | switch ($type) { |
|
| 50 | case 'magento': |
|
| 51 | return "cd /var/www/public;../bin/n98-magerun.phar cache:clean $cacheType"; |
|
| 52 | case 'magento2': |
|
| 53 | return "cd /var/www/public;bin/magento cache:clean $cacheType"; |
|
| 54 | } |
|
| 55 | ||
| 56 | return false; |
|
| 57 | } |
|
| 58 | } |
|
| @@ 14-58 (lines=45) @@ | ||
| 11 | * Class DisableCommand |
|
| 12 | * @package Magestead\Command\Cache |
|
| 13 | */ |
|
| 14 | class DisableCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("cache:disable"); |
|
| 23 | $this->setDescription("Disable cache types"); |
|
| 24 | $this->addArgument('type', InputArgument::OPTIONAL, '[cache code/type]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $output->writeln('<info>Disabling all cache types</info>'); |
|
| 35 | ||
| 36 | $cacheType = $input->getArgument('type'); |
|
| 37 | $command = $this->getCommand(new Config($output), $cacheType); |
|
| 38 | $pCommand = "vagrant ssh -c '". $command ."'"; |
|
| 39 | return new ProcessCommand($pCommand, $this->_projectPath, $output); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @param Config $config |
|
| 44 | * @return bool|string |
|
| 45 | */ |
|
| 46 | protected function getCommand(Config $config, $cacheType) |
|
| 47 | { |
|
| 48 | $type = $config->type; |
|
| 49 | switch ($type) { |
|
| 50 | case 'magento': |
|
| 51 | return "cd /var/www/public;../bin/n98-magerun.phar cache:disable $cacheType"; |
|
| 52 | case 'magento2': |
|
| 53 | return "cd /var/www/public;bin/magento cache:disable $cacheType"; |
|
| 54 | } |
|
| 55 | ||
| 56 | return false; |
|
| 57 | } |
|
| 58 | } |
|
| @@ 14-58 (lines=45) @@ | ||
| 11 | * Class EnableCommand |
|
| 12 | * @package Magestead\Command\Cache |
|
| 13 | */ |
|
| 14 | class EnableCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("cache:enable"); |
|
| 23 | $this->setDescription("Enable cache types"); |
|
| 24 | $this->addArgument('type', InputArgument::OPTIONAL, '[cache code/type]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $output->writeln('<info>Enabling all cache types</info>'); |
|
| 35 | ||
| 36 | $cacheType = $input->getArgument('type'); |
|
| 37 | $command = $this->getCommand(new Config($output), $cacheType); |
|
| 38 | $pCommand = "vagrant ssh -c '". $command ."'"; |
|
| 39 | return new ProcessCommand($pCommand, $this->_projectPath, $output); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @param Config $config |
|
| 44 | * @return bool|string |
|
| 45 | */ |
|
| 46 | protected function getCommand(Config $config, $cacheType) |
|
| 47 | { |
|
| 48 | $type = $config->type; |
|
| 49 | switch ($type) { |
|
| 50 | case 'magento': |
|
| 51 | return "cd /var/www/public;../bin/n98-magerun.phar cache:enable $cacheType"; |
|
| 52 | case 'magento2': |
|
| 53 | return "cd /var/www/public;bin/magento cache:enable $cacheType"; |
|
| 54 | } |
|
| 55 | ||
| 56 | return false; |
|
| 57 | } |
|
| 58 | } |
|
| @@ 14-58 (lines=45) @@ | ||
| 11 | * Class FlushCommand |
|
| 12 | * @package Magestead\Command\Cache |
|
| 13 | */ |
|
| 14 | class FlushCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("cache:flush"); |
|
| 23 | $this->setDescription("Flushes cache storage used by cache types"); |
|
| 24 | $this->addArgument('type', InputArgument::OPTIONAL, '[cache code/type]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $output->writeln('<info>Flushing cache storage</info>'); |
|
| 35 | ||
| 36 | $cacheType = $input->getArgument('type'); |
|
| 37 | $command = $this->getCommand(new Config($output), $cacheType); |
|
| 38 | $pCommand = "vagrant ssh -c '". $command ."'"; |
|
| 39 | return new ProcessCommand($pCommand, $this->_projectPath, $output); |
|
| 40 | } |
|
| 41 | ||
| 42 | /** |
|
| 43 | * @param Config $config |
|
| 44 | * @return bool|string |
|
| 45 | */ |
|
| 46 | protected function getCommand(Config $config, $cacheType) |
|
| 47 | { |
|
| 48 | $type = $config->type; |
|
| 49 | switch ($type) { |
|
| 50 | case 'magento': |
|
| 51 | return "cd /var/www/public;../bin/n98-magerun.phar cache:flush $cacheType"; |
|
| 52 | case 'magento2': |
|
| 53 | return "cd /var/www/public;bin/magento cache:flush $cacheType"; |
|
| 54 | } |
|
| 55 | ||
| 56 | return false; |
|
| 57 | } |
|
| 58 | } |
|
| @@ 14-60 (lines=47) @@ | ||
| 11 | * Class SetModeCommand |
|
| 12 | * @package Magestead\Command\Index |
|
| 13 | */ |
|
| 14 | class SetModeCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("index:mode:set"); |
|
| 23 | $this->setDescription("Set index mode type"); |
|
| 24 | $this->addArgument('mode', InputArgument::REQUIRED, '{realtime|schedule} [indexer]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand|null |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $indexMode = $input->getArgument('mode'); |
|
| 35 | $command = $this->getCommand(new Config($output), $indexMode); |
|
| 36 | if ($command) { |
|
| 37 | $output->writeln('<info>Setting index mode</info>'); |
|
| 38 | $pCommand = "vagrant ssh -c '". $command ."'"; |
|
| 39 | return new ProcessCommand($pCommand, $this->_projectPath, $output); |
|
| 40 | } |
|
| 41 | ||
| 42 | $output->writeln('<error>Command not available for this application</error>'); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @param Config $config |
|
| 47 | * @param $mode |
|
| 48 | * @return bool|string |
|
| 49 | */ |
|
| 50 | protected function getCommand(Config $config, $mode) |
|
| 51 | { |
|
| 52 | $type = $config->type; |
|
| 53 | switch ($type) { |
|
| 54 | case 'magento2': |
|
| 55 | return "cd /var/www/public;bin/magento indexer:set-mode $mode"; |
|
| 56 | } |
|
| 57 | ||
| 58 | return false; |
|
| 59 | } |
|
| 60 | } |
|
| @@ 14-61 (lines=48) @@ | ||
| 11 | * Class ShowModeCommand |
|
| 12 | * @package Magestead\Command\Index |
|
| 13 | */ |
|
| 14 | class ShowModeCommand extends Command |
|
| 15 | { |
|
| 16 | protected $_config; |
|
| 17 | protected $_projectPath; |
|
| 18 | ||
| 19 | protected function configure() |
|
| 20 | { |
|
| 21 | $this->_projectPath = getcwd(); |
|
| 22 | $this->setName("index:mode:show"); |
|
| 23 | $this->setDescription("Show index mode"); |
|
| 24 | $this->addArgument('index', InputArgument::OPTIONAL, '[indexer]'); |
|
| 25 | } |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param InputInterface $input |
|
| 29 | * @param OutputInterface $output |
|
| 30 | * @return ProcessCommand|null |
|
| 31 | */ |
|
| 32 | protected function execute(InputInterface $input, OutputInterface $output) |
|
| 33 | { |
|
| 34 | $index = $input->getArgument('index'); |
|
| 35 | ||
| 36 | $command = $this->getCommand(new Config($output), $index); |
|
| 37 | if ($command) { |
|
| 38 | $output->writeln('<info>Getting index mode</info>'); |
|
| 39 | $passedCommand = "vagrant ssh -c '". $command ."'"; |
|
| 40 | return new ProcessCommand($passedCommand, $this->_projectPath, $output); |
|
| 41 | } |
|
| 42 | ||
| 43 | $output->writeln('<error>Command not available for this application</error>'); |
|
| 44 | } |
|
| 45 | ||
| 46 | /** |
|
| 47 | * @param Config $config |
|
| 48 | * @param $index |
|
| 49 | * @return bool|string |
|
| 50 | */ |
|
| 51 | protected function getCommand(Config $config, $index) |
|
| 52 | { |
|
| 53 | $type = $config->type; |
|
| 54 | switch ($type) { |
|
| 55 | case 'magento2': |
|
| 56 | return "cd /var/www/public;bin/magento indexer:show-mode $index"; |
|
| 57 | } |
|
| 58 | ||
| 59 | return false; |
|
| 60 | } |
|
| 61 | } |
|