1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Setup\Model;
use Zend\ServiceManager\ServiceLocatorInterface;
use Magento\Setup\Module\ResourceFactory;
use Magento\Framework\App\ErrorHandler;
use Magento\Framework\Setup\LoggerInterface;
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class InstallerFactory
{
/**
* Zend Framework's service locator
*
* @var ServiceLocatorInterface
*/
protected $serviceLocator;
/**
* @var ResourceFactory
*/
private $resourceFactory;
/**
* Constructor
*
* @param ServiceLocatorInterface $serviceLocator
* @param ResourceFactory $resourceFactory
*/
public function __construct(
ServiceLocatorInterface $serviceLocator,
ResourceFactory $resourceFactory
) {
$this->serviceLocator = $serviceLocator;
$this->resourceFactory = $resourceFactory;
// For Setup Wizard we are using our customized error handler
$handler = new ErrorHandler();
set_error_handler([$handler, 'handler']);
}
/**
* Factory method for installer object
*
* @param LoggerInterface $log
* @return Installer
*/
public function create(LoggerInterface $log)
{
return new Installer(
$this->serviceLocator->get(\Magento\Framework\Setup\FilePermissions::class),
$this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig\Writer::class),
$this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig\Reader::class),
$this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig::class),
$this->serviceLocator->get(\Magento\Framework\Module\ModuleList::class),
$this->serviceLocator->get(\Magento\Framework\Module\ModuleList\Loader::class),
$this->serviceLocator->get(\Magento\Setup\Model\AdminAccountFactory::class),
$log,
$this->serviceLocator->get(\Magento\Setup\Module\ConnectionFactory::class),
$this->serviceLocator->get(\Magento\Framework\App\MaintenanceMode::class),
$this->serviceLocator->get(\Magento\Framework\Filesystem::class),
$this->serviceLocator->get(\Magento\Setup\Model\ObjectManagerProvider::class),
new \Magento\Framework\Model\ResourceModel\Db\Context(
$this->getResource(),
$this->serviceLocator->get(\Magento\Framework\Model\ResourceModel\Db\TransactionManager::class),
$this->serviceLocator->get(\Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor::class)
),
$this->serviceLocator->get(\Magento\Setup\Model\ConfigModel::class),
$this->serviceLocator->get(\Magento\Framework\App\State\CleanupFiles::class),
$this->serviceLocator->get(\Magento\Setup\Validator\DbValidator::class),
$this->serviceLocator->get(\Magento\Setup\Module\SetupFactory::class),
$this->serviceLocator->get(\Magento\Setup\Module\DataSetupFactory::class),
$this->serviceLocator->get(\Magento\Framework\Setup\SampleData\State::class),
new \Magento\Framework\Component\ComponentRegistrar(),
$this->serviceLocator->get(\Magento\Setup\Model\PhpReadinessCheck::class)
);
}
/**
* creates Resource Factory
*
* @return Resource
*/
private function getResource()
{
$deploymentConfig = $this->serviceLocator->get(\Magento\Framework\App\DeploymentConfig::class);
return $this->resourceFactory->create($deploymentConfig);
}
}