Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddNonSpecifiedGenderAttributeOption.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Customer\Setup\CustomerSetupFactory;
26 
32 {
36  private $moduleDataSetup;
37 
41  private $customerSetupFactory;
42 
48  public function __construct(
49  ModuleDataSetupInterface $moduleDataSetup,
50  CustomerSetupFactory $customerSetupFactory
51  ) {
52  $this->moduleDataSetup = $moduleDataSetup;
53  $this->customerSetupFactory = $customerSetupFactory;
54  }
55 
59  public function apply()
60  {
61  $customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
62  $entityTypeId = $customerSetup->getEntityTypeId(Customer::ENTITY);
63  $attributeId = $customerSetup->getAttributeId($entityTypeId, 'gender');
64 
65  $option = ['attribute_id' => $attributeId, 'values' => [3 => 'Not Specified']];
66  $customerSetup->addAttributeOption($option);
67  }
68 
72  public static function getDependencies()
73  {
74  return [
75  UpdateCustomerAttributesMetadata::class,
76  ];
77  }
78 
82  public static function getVersion()
83  {
84  return '2.0.2';
85  }
86 
90  public function getAliases()
91  {
92  return [];
93  }
94 }
__construct(ModuleDataSetupInterface $moduleDataSetup, CustomerSetupFactory $customerSetupFactory)