Skip to content

Instantly share code, notes, and snippets.

@roma-glushko
Created November 10, 2016 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save roma-glushko/da754c3fa77c99a02b760f98fbd044f1 to your computer and use it in GitHub Desktop.
Save roma-glushko/da754c3fa77c99a02b760f98fbd044f1 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