UserConfig.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. /**
  21. * Automatically created by MageSpecialist CodeMonkey
  22. * https://github.com/magespecialist/m2-MSP_CodeMonkey
  23. */
  24. namespace MSP\TwoFactorAuth\Model;
  25. use Magento\Framework\Model\AbstractModel;
  26. use Magento\Framework\Api\DataObjectHelper;
  27. use Magento\Framework\Data\Collection\AbstractDb;
  28. use Magento\Framework\Model\Context;
  29. use Magento\Framework\Model\ResourceModel\AbstractResource;
  30. use Magento\Framework\Registry;
  31. /**
  32. * @SuppressWarnings(PHPMD.LongVariable)
  33. * @SuppressWarnings(PHPMD.CamelCaseMethodName)
  34. */
  35. class UserConfig extends AbstractModel
  36. {
  37. /**
  38. * @var DataObjectHelper
  39. */
  40. private $dataObjectHelper;
  41. /**
  42. * @var \MSP\TwoFactorAuth\Api\Data\UserConfigInterfaceFactory
  43. */
  44. private $userConfigDataFactory;
  45. public function __construct(
  46. Context $context,
  47. Registry $registry,
  48. DataObjectHelper $dataObjectHelper,
  49. \MSP\TwoFactorAuth\Api\Data\UserConfigInterfaceFactory $userConfigDataFactory,
  50. AbstractResource $resource = null,
  51. AbstractDb $resourceCollection = null,
  52. array $data = []
  53. ) {
  54. parent::__construct($context, $registry, $resource, $resourceCollection, $data);
  55. $this->dataObjectHelper = $dataObjectHelper;
  56. $this->userConfigDataFactory = $userConfigDataFactory;
  57. }
  58. protected function _construct()
  59. {
  60. $this->_init(\MSP\TwoFactorAuth\Model\ResourceModel\UserConfig::class);
  61. }
  62. /**
  63. * Retrieve UserConfig model
  64. *
  65. * @return \MSP\TwoFactorAuth\Api\Data\UserConfigInterface
  66. */
  67. public function getDataModel()
  68. {
  69. $userConfigData = $this->getData();
  70. /** @var \MSP\TwoFactorAuth\Api\Data\UserConfigInterface $userConfigDataObject */
  71. $userConfigDataObject = $this->userConfigDataFactory->create();
  72. $this->dataObjectHelper->populateWithArray(
  73. $userConfigDataObject,
  74. $userConfigData,
  75. \MSP\TwoFactorAuth\Api\Data\UserConfigInterface::class
  76. );
  77. $userConfigDataObject->setId($this->getId());
  78. return $userConfigDataObject;
  79. }
  80. }