ReCaptcha.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * IDEALIAGroup srl
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to info@idealiagroup.com so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_ReCaptcha
  17. * @copyright Copyright (c) 2016 IDEALIAGroup srl (http://www.idealiagroup.com)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\ReCaptcha\Command;
  21. use Magento\Framework\App\Cache\Manager;
  22. use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
  23. use MSP\ReCaptcha\Model\Config;
  24. use Symfony\Component\Console\Command\Command;
  25. use Symfony\Component\Console\Input\InputInterface;
  26. use Symfony\Component\Console\Output\OutputInterface;
  27. class ReCaptcha extends Command
  28. {
  29. /**
  30. * @var ConfigInterface
  31. */
  32. private $config;
  33. /**
  34. * @var Manager
  35. */
  36. private $cacheManager;
  37. /**
  38. * ReCaptcha constructor.
  39. * @param ConfigInterface $config
  40. * @param Manager $cacheManager
  41. */
  42. public function __construct(
  43. ConfigInterface $config,
  44. Manager $cacheManager
  45. ) {
  46. parent::__construct();
  47. $this->config = $config;
  48. $this->cacheManager = $cacheManager;
  49. }
  50. /**
  51. * @inheritdoc
  52. */
  53. protected function configure()
  54. {
  55. $this->setName('msp:security:recaptcha:disable');
  56. $this->setDescription('Disable backend reCaptcha');
  57. parent::configure();
  58. }
  59. /**
  60. * @inheritdoc
  61. * @SuppressWarnings("PHPMD.UnusedFormalParameter")
  62. */
  63. protected function execute(InputInterface $input, OutputInterface $output)
  64. {
  65. $this->config->saveConfig(
  66. Config::XML_PATH_ENABLED_BACKEND,
  67. '0',
  68. 'default',
  69. 0
  70. );
  71. $this->cacheManager->flush(['config']);
  72. }
  73. }