Files
ltsecurityinc/app/code/Lts/Customer/Setup/Patch/Data/UpdateCustomerAddressAttributesCompany.php
T

95 lines
2.3 KiB
PHP

<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Lts\Customer\Setup\Patch\Data;
use Magento\Customer\Setup\CustomerSetup;
use Magento\Customer\Setup\CustomerSetupFactory;
use Magento\Customer\Setup\Patch\Data\DefaultCustomerGroupsAndAttributes;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;
/**
* Update Customer Address Attributes to be displayed in following order: country, region, city, postcode
*/
class UpdateCustomerAddressAttributesCompany implements DataPatchInterface
{
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
/**
* @var CustomerSetupFactory
*/
private $customerSetupFactory;
/**
* UpdateCustomerAddressAttributesSortOrder constructor.
* @param ModuleDataSetupInterface $moduleDataSetup
* @param CustomerSetupFactory $customerSetupFactory
*/
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
CustomerSetupFactory $customerSetupFactory
) {
$this->moduleDataSetup = $moduleDataSetup;
$this->customerSetupFactory = $customerSetupFactory;
}
/**
* @inheritDoc
*/
public function apply()
{
/** @var CustomerSetup $customerSetup */
$customerSetup = $this->customerSetupFactory->create(['setup' => $this->moduleDataSetup]);
$this->update($customerSetup);
return $this;
}
/**
* @inheritDoc
*/
public function getAliases()
{
return [];
}
/**
* @inheritDoc
*/
public static function getDependencies()
{
return [
DefaultCustomerGroupsAndAttributes::class,
];
}
/**
* Update customer address attributes sort order
*
* @param CustomerSetup $customerSetup
*
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
private function update($customerSetup)
{
$entityAttributes = [
'customer_address' => [
'company' => [
'is_required' => 0,
]
],
];
$customerSetup->upgradeAttributes($entityAttributes);
}
}