AddSecurityTrackingAttributes.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Setup\Patch\Data;
  7. use Magento\Customer\Model\Customer;
  8. use Magento\Customer\Setup\CustomerSetupFactory;
  9. use Magento\Framework\App\ResourceConnection;
  10. use Magento\Framework\Setup\ModuleDataSetupInterface;
  11. use Magento\Framework\Setup\Patch\DataPatchInterface;
  12. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  13. /**
  14. * Class AddSecurityTrackingAttributes
  15. * @package Magento\Customer\Setup\Patch
  16. */
  17. class AddSecurityTrackingAttributes implements DataPatchInterface, PatchVersionInterface
  18. {
  19. /**
  20. * @var ModuleDataSetupInterface
  21. */
  22. private $moduleDataSetup;
  23. /**
  24. * @var CustomerSetupFactory
  25. */
  26. private $customerSetupFactory;
  27. /**
  28. * AddSecurityTrackingAttributes constructor.
  29. * @param ModuleDataSetupInterface $moduleDataSetup
  30. * @param CustomerSetupFactory $customerSetupFactory
  31. */
  32. public function __construct(
  33. ModuleDataSetupInterface $moduleDataSetup,
  34. CustomerSetupFactory $customerSetupFactory
  35. ) {
  36. $this->moduleDataSetup = $moduleDataSetup;
  37. $this->customerSetupFactory = $customerSetupFactory;
  38. }
  39. /**
  40. * {@inheritdoc}
  41. */
  42. public function apply()
  43. {
  44. $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
  45. $customerSetup->addAttribute(
  46. Customer::ENTITY,
  47. 'failures_num',
  48. [
  49. 'type' => 'static',
  50. 'label' => 'Failures Number',
  51. 'input' => 'hidden',
  52. 'required' => false,
  53. 'sort_order' => 100,
  54. 'visible' => false,
  55. 'system' => true,
  56. ]
  57. );
  58. $customerSetup->addAttribute(
  59. Customer::ENTITY,
  60. 'first_failure',
  61. [
  62. 'type' => 'static',
  63. 'label' => 'First Failure Date',
  64. 'input' => 'date',
  65. 'required' => false,
  66. 'sort_order' => 110,
  67. 'visible' => false,
  68. 'system' => true,
  69. ]
  70. );
  71. $customerSetup->addAttribute(
  72. Customer::ENTITY,
  73. 'lock_expires',
  74. [
  75. 'type' => 'static',
  76. 'label' => 'Failures Number',
  77. 'input' => 'date',
  78. 'required' => false,
  79. 'sort_order' => 120,
  80. 'visible' => false,
  81. 'system' => true,
  82. ]
  83. );
  84. $configTable = $this->moduleDataSetup->getTable('core_config_data');
  85. $this->moduleDataSetup->getConnection()->update(
  86. $configTable,
  87. ['value' => new \Zend_Db_Expr('value*24')],
  88. ['path = ?' => \Magento\Customer\Model\Customer::XML_PATH_CUSTOMER_RESET_PASSWORD_LINK_EXPIRATION_PERIOD]
  89. );
  90. }
  91. /**
  92. * {@inheritdoc}
  93. */
  94. public static function getDependencies()
  95. {
  96. return [
  97. RemoveCheckoutRegisterAndUpdateAttributes::class,
  98. ];
  99. }
  100. /**
  101. * {@inheritdoc}
  102. */
  103. public static function getVersion()
  104. {
  105. return '2.0.7';
  106. }
  107. /**
  108. * {@inheritdoc}
  109. */
  110. public function getAliases()
  111. {
  112. return [];
  113. }
  114. }