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/app/code/Ecombricks/Common/DataObject/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/app/code/Ecombricks/Common/DataObject/WrapperFactory.php
<?php
/**
 * Copyright © eComBricks. All rights reserved.
 * See LICENSE.txt for license details.
 */
declare(strict_types=1);

namespace Ecombricks\Common\DataObject;

/**
 * Object wrapper factory
 */
class WrapperFactory
{
    /**
     * Object manager
     * 
     * @var \Magento\Framework\ObjectManagerInterface
     */
    private $objectManager;

    /**
     * Wrappers
     * 
     * @var array
     */
    private $wrappers = [];

    /**
     * Constructor
     *
     * @param \Magento\Framework\ObjectManagerInterface $objectManager
     */
    public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager)
    {
        $this->objectManager = $objectManager;
    }

    /**
     * Create
     * 
     * @param object $object
     * @param string $instanceName
     * @return object
     */
    public function create($object, string $instanceName = \Ecombricks\Common\DataObject\Wrapper::class)
    {
        $objectId = spl_object_id($object);
        if (array_key_exists($objectId, $this->wrappers) && array_key_exists($instanceName, $this->wrappers[$objectId])) {
            return $this->wrappers[$objectId][$instanceName];
        }
        return $this->wrappers[$objectId][$instanceName] = $this->objectManager->create($instanceName)->setObject($object);
    }

    /**
     * Clear
     * 
     * @return void
     */
    public function clear(): void
    {
        $this->wrappers = [];
    }
}

Spamworldpro Mini