Skip to content

Instantly share code, notes, and snippets.

@rodde177
Forked from roma-glushko/ObjectManagerFactory.php
Created December 1, 2016 14:59
Show Gist options
  • Save rodde177/21b3cfab86317d693b082a89dba07be9 to your computer and use it in GitHub Desktop.
Save rodde177/21b3cfab86317d693b082a89dba07be9 to your computer and use it in GitHub Desktop.
<?php
namespace Vendor\Module\Test\Unit;
use Magento\Framework\App\ObjectManagerFactory as AppObjectManagerFactory;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\App\Filesystem\DirectoryList;
/**
* Class ObjectManagerFactory
*/
class ObjectManagerFactory
{
/**
* @return ObjectManagerInterface
*/
public function create($args = [])
{
return $this->createObjectManagerFactory()->create($args);
}
/**
* @return AppObjectManagerFactory
*/
protected function createObjectManagerFactory()
{
$driverPool = $this->createDriverPool();
$directoryList = $this->createDirectoryList();
$configFilePool = $this->createConfigFilePool();
return new AppObjectManagerFactory($directoryList, $driverPool, $configFilePool);
}
/**
* @return DriverPool
*/
protected function createDriverPool()
{
return new DriverPool([
'file' => File::class
]);
}
/**
* @return DirectoryList
*/
protected function createDirectoryList()
{
return new DirectoryList(BP, [
'base' => [
'path' => BP
]
]);
}
/**
* @return ConfigFilePool
*/
protected function createConfigFilePool()
{
return new ConfigFilePool();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment