Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DefinitionFactory.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
22  protected $_generationDir;
23 
29  protected $_filesystemDriver;
30 
34  protected $codeGenerator;
35 
40  public function __construct(
41  DriverInterface $filesystemDriver,
42  $generationDir
43  ) {
44  $this->_filesystemDriver = $filesystemDriver;
45  $this->_generationDir = $generationDir;
46  }
47 
53  public function createClassDefinition()
54  {
55  $autoloader = new Autoloader($this->getCodeGenerator());
56  spl_autoload_register([$autoloader, 'load']);
57  return new Runtime();
58  }
59 
65  public function createPluginDefinition()
66  {
67  return new \Magento\Framework\Interception\Definition\Runtime();
68  }
69 
75  public function createRelations()
76  {
77  return new \Magento\Framework\ObjectManager\Relations\Runtime();
78  }
79 
85  public function getCodeGenerator()
86  {
87  if (!$this->codeGenerator) {
88  $generatorIo = new \Magento\Framework\Code\Generator\Io(
89  $this->_filesystemDriver,
90  $this->_generationDir
91  );
92  $this->codeGenerator = new \Magento\Framework\Code\Generator($generatorIo);
93  }
94  return $this->codeGenerator;
95  }
96 }
$generatorIo
Definition: autoload.php:15
__construct(DriverInterface $filesystemDriver, $generationDir)