Magento 2
Generated Code
Free Preview
generated/code/Magento/Customer/Model/AddressFactory.php
<?php
/**
 * While this file is in the Magento\Customer\Model namespace, all generated
 * code resides in the "generated" folder of your project root. For example,
 * this class resides in a file within: generated/code/Magento/Customer/Model
 *
 * While in developer mode, if a dynamic file is requested by the Object
 * Manager, it is automatically created if it does not yet exist.
 *
 * While in production mode, files are not automatically created but are
 * generated when the "bin/magento setup:di:compile" command is executed.
 * This is why this command is required to be ran when deploying new code.
 *
 * Notice how Object Manager is used directly in this class. This is one of
 * the edge-cases in which direct use of Object Manager is acceptable. While
 * this class is dynamically created, you can also create your own classes
 * locally if the generated version does not suffice for your needs.
 */

namespace Magento\Customer\Model;

/**
 * Factory class for @see \Magento\Customer\Model\Address
 */
class AddressFactory
{
    /**
     * Object Manager instance
     *
     * @var \Magento\Framework\ObjectManagerInterface
     */
    protected $_objectManager = null;

    /**
     * Instance name to create
     *
     * @var string
     */
    protected $_instanceName = null;

    /**
     * Factory constructor
     *
     * @param \Magento\Framework\ObjectManagerInterface $objectManager
     * @param string $instanceName
     */
    public function __construct(
        \Magento\Framework\ObjectManagerInterface $objectManager,
        $instanceName = '\\Magento\\Customer\\Model\\Address'
    ) {
        $this->_objectManager = $objectManager;
        $this->_instanceName = $instanceName;
    }

    /**
     * Create class instance with specified parameters
     *
     * @param array $data
     * @return \Magento\Customer\Model\Address
     */
    public function create(array $data = [])
    {
        return $this->_objectManager->create($this->_instanceName, $data);
    }
}
Want to learn more?

Visit M.academy to learn much more about Magento, Laravel, PHP, Javascript, & Docker.

M.academy logo