Configure.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_TwoFactorAuth
  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\TwoFactorAuth\Block\Provider\Authy;
  21. use Magento\Backend\Block\Template;
  22. use MSP\TwoFactorAuth\Model\ResourceModel\Country\CollectionFactory as CountryCollectionFactory;
  23. /**
  24. * @SuppressWarnings(PHPMD.LongVariable)
  25. */
  26. class Configure extends Template
  27. {
  28. /**
  29. * @var CountryCollectionFactory
  30. */
  31. private $countryCollectionFactory;
  32. public function __construct(
  33. Template\Context $context,
  34. CountryCollectionFactory $countryCollectionFactory,
  35. array $data = []
  36. ) {
  37. parent::__construct($context, $data);
  38. $this->countryCollectionFactory = $countryCollectionFactory;
  39. }
  40. /**
  41. * Get a country list
  42. * return array
  43. */
  44. private function getCountriesList()
  45. {
  46. return $this->countryCollectionFactory->create()->addOrder('name', 'asc')->getItems();
  47. }
  48. /**
  49. * @inheritdoc
  50. */
  51. public function getJsLayout()
  52. {
  53. $countries = [];
  54. foreach ($this->getCountriesList() as $country) {
  55. $countries[] = [
  56. 'dial_code' => $country->getDialCode(),
  57. 'name' => $country->getName(),
  58. ];
  59. }
  60. $this->jsLayout['components']['msp-twofactorauth-configure']['children']['register']['configurePostUrl'] =
  61. $this->getUrl('*/*/configurepost');
  62. $this->jsLayout['components']['msp-twofactorauth-configure']['children']['verify']['verifyPostUrl'] =
  63. $this->getUrl('*/*/configureverifypost');
  64. $this->jsLayout['components']['msp-twofactorauth-configure']['children']['verify']['successUrl'] =
  65. $this->getUrl($this->_urlBuilder->getStartupPageUrl());
  66. $this->jsLayout['components']['msp-twofactorauth-configure']['children']['register']['countries'] =
  67. $countries;
  68. return parent::getJsLayout();
  69. }
  70. }