AddCustomerUpdatedAtAttribute.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 AddCustomerUpdatedAtAttribute
  15. * @package Magento\Customer\Setup\Patch
  16. */
  17. class AddCustomerUpdatedAtAttribute implements DataPatchInterface, PatchVersionInterface
  18. {
  19. /**
  20. * @var ModuleDataSetupInterface
  21. */
  22. private $moduleDataSetup;
  23. /**
  24. * @var CustomerSetupFactory
  25. */
  26. private $customerSetupFactory;
  27. /**
  28. * AddCustomerUpdatedAtAttribute 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. 'updated_at',
  48. [
  49. 'type' => 'static',
  50. 'label' => 'Updated At',
  51. 'input' => 'date',
  52. 'required' => false,
  53. 'sort_order' => 87,
  54. 'visible' => false,
  55. 'system' => false,
  56. ]
  57. );
  58. }
  59. /**
  60. * {@inheritdoc}
  61. */
  62. public static function getDependencies()
  63. {
  64. return [
  65. UpdateIdentifierCustomerAttributesVisibility::class,
  66. ];
  67. }
  68. /**
  69. * {@inheritdoc}
  70. */
  71. public static function getVersion()
  72. {
  73. return '2.0.4';
  74. }
  75. /**
  76. * {@inheritdoc}
  77. */
  78. public function getAliases()
  79. {
  80. return [];
  81. }
  82. }