UpdateVATNumber.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\Directory\Model\AllowedCountries;
  10. use Magento\Framework\App\ObjectManager;
  11. use Magento\Framework\Encryption\Encryptor;
  12. use Magento\Framework\Indexer\IndexerRegistry;
  13. use Magento\Framework\Setup\SetupInterface;
  14. use Magento\Framework\Setup\UpgradeDataInterface;
  15. use Magento\Framework\Setup\ModuleContextInterface;
  16. use Magento\Framework\Setup\ModuleDataSetupInterface;
  17. use Magento\Store\Model\ScopeInterface;
  18. use Magento\Store\Model\StoreManagerInterface;
  19. use Magento\Framework\DB\FieldDataConverterFactory;
  20. use Magento\Framework\DB\DataConverter\SerializedToJson;
  21. use Magento\Framework\App\ResourceConnection;
  22. use Magento\Framework\Setup\Patch\DataPatchInterface;
  23. use Magento\Framework\Setup\Patch\PatchVersionInterface;
  24. class UpdateVATNumber implements DataPatchInterface, PatchVersionInterface
  25. {
  26. /**
  27. * @var ModuleDataSetupInterface
  28. */
  29. private $moduleDataSetup;
  30. /**
  31. * @var CustomerSetupFactory
  32. */
  33. private $customerSetupFactory;
  34. /**
  35. * UpdateVATNumber constructor.
  36. * @param ModuleDataSetupInterface $moduleDataSetup
  37. * @param CustomerSetupFactory $customerSetupFactory
  38. */
  39. public function __construct(
  40. ModuleDataSetupInterface $moduleDataSetup,
  41. CustomerSetupFactory $customerSetupFactory
  42. ) {
  43. $this->moduleDataSetup = $moduleDataSetup;
  44. $this->customerSetupFactory = $customerSetupFactory;
  45. }
  46. /**
  47. * {@inheritdoc}
  48. */
  49. public function apply()
  50. {
  51. $customerSetup = $this->customerSetupFactory->create(['resourceConnection' => $this->moduleDataSetup]);
  52. $customerSetup->updateAttribute('customer_address', 'vat_id', 'frontend_label', 'VAT Number');
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public static function getDependencies()
  58. {
  59. return [
  60. ConvertValidationRulesFromSerializedToJson::class,
  61. ];
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public static function getVersion()
  67. {
  68. return '2.0.12';
  69. }
  70. /**
  71. * {@inheritdoc}
  72. */
  73. public function getAliases()
  74. {
  75. return [];
  76. }
  77. }