1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MagentoHackathon\Composer\Magento\Factory; |
4
|
|
|
|
5
|
|
|
use Composer\Package\PackageInterface; |
6
|
|
|
use MagentoHackathon\Composer\Magento\Deploystrategy\DeploystrategyAbstract; |
7
|
|
|
use MagentoHackathon\Composer\Magento\ProjectConfig; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class InstallStrategyFactory |
11
|
|
|
* @package MagentoHackathon\Composer\Magento\Deploystrategy |
12
|
|
|
*/ |
13
|
|
|
class InstallStrategyFactory |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* @var ProjectConfig |
18
|
|
|
*/ |
19
|
|
|
protected $config; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var ParserFactoryInterface |
23
|
|
|
*/ |
24
|
|
|
protected $parserFactory; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @param ProjectConfig $config |
28
|
|
|
* @param ParserFactoryInterface $parserFactory |
29
|
|
|
*/ |
30
|
7 |
|
public function __construct(ProjectConfig $config, ParserFactoryInterface $parserFactory) |
31
|
|
|
{ |
32
|
7 |
|
$this->config = $config; |
33
|
7 |
|
$this->parserFactory = $parserFactory; |
34
|
7 |
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @param PackageInterface $package |
38
|
|
|
* @param string $packageSourcePath |
39
|
|
|
* @return DeploystrategyAbstract |
40
|
|
|
*/ |
41
|
5 |
|
public function make(PackageInterface $package, $packageSourcePath) |
42
|
|
|
{ |
43
|
5 |
|
$strategyName = $this->config->getModuleSpecificDeployStrategy($package->getName()); |
44
|
|
|
|
45
|
5 |
|
$ns = '\MagentoHackathon\Composer\Magento\Deploystrategy\\'; |
46
|
5 |
|
$className = $ns . ucfirst($strategyName); |
47
|
5 |
|
if (!class_exists($className)) { |
48
|
5 |
|
$className = $ns . 'Symlink'; |
49
|
5 |
|
} |
50
|
|
|
|
51
|
5 |
|
$strategy = new $className($packageSourcePath, realpath($this->config->getMagentoRootDir())); |
52
|
5 |
|
$strategy->setIgnoredMappings($this->config->getModuleSpecificDeployIgnores($package->getName())); |
53
|
5 |
|
$strategy->setIsForced($this->config->getMagentoForceByPackageName($package->getName())); |
54
|
|
|
|
55
|
5 |
|
$mappingParser = $this->parserFactory->make($package, $packageSourcePath); |
56
|
5 |
|
$strategy->setMappings($mappingParser->getMappings()); |
57
|
|
|
|
58
|
5 |
|
return $strategy; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|