AuthenticationPopupPlugin.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * MageSpecialist
  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@magespecialist.it so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_ReCaptcha
  17. * @copyright Copyright (c) 2017 Skeeller srl (http://www.magespecialist.it)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\ReCaptcha\Plugin\Block\Account;
  21. use Magento\Framework\Json\DecoderInterface;
  22. use Magento\Framework\Json\EncoderInterface;
  23. use MSP\ReCaptcha\Model\LayoutSettings;
  24. class AuthenticationPopupPlugin
  25. {
  26. /**
  27. * @var EncoderInterface
  28. */
  29. private $encoder;
  30. /**
  31. * @var DecoderInterface
  32. */
  33. private $decoder;
  34. /**
  35. * @var LayoutSettings
  36. */
  37. private $layoutSettings;
  38. /**
  39. * AuthenticationPopupPlugin constructor.
  40. * @param EncoderInterface $encoder
  41. * @param DecoderInterface $decoder
  42. * @param LayoutSettings $layoutSettings
  43. */
  44. public function __construct(
  45. EncoderInterface $encoder,
  46. DecoderInterface $decoder,
  47. LayoutSettings $layoutSettings
  48. ) {
  49. $this->encoder = $encoder;
  50. $this->decoder = $decoder;
  51. $this->layoutSettings = $layoutSettings;
  52. }
  53. /**
  54. * @param \Magento\Customer\Block\Account\AuthenticationPopup $subject
  55. * @param array $result
  56. * @return string
  57. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  58. */
  59. public function afterGetJsLayout(\Magento\Customer\Block\Account\AuthenticationPopup $subject, $result)
  60. {
  61. $layout = $this->decoder->decode($result);
  62. $layout['components']['authenticationPopup']['children']['msp_recaptcha']['settings'] =
  63. $this->layoutSettings->getCaptchaSettings();
  64. return $this->encoder->encode($layout);
  65. }
  66. }