1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace MagentoHackathon\Composer\Magento\Factory; |
4
|
|
|
|
5
|
|
|
use Composer\Package\PackageInterface; |
6
|
|
|
use MagentoHackathon\Composer\Magento\Deploy\Manager\Entry; |
7
|
|
|
use MagentoHackathon\Composer\Magento\Factory\ParserFactoryInterface; |
8
|
|
|
use MagentoHackathon\Composer\Magento\ProjectConfig; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class EntryFactory |
12
|
|
|
* @package MagentoHackathon\Composer\Magento\Deploy\Manager |
13
|
|
|
* @author Aydin Hassan <[email protected]> |
14
|
|
|
*/ |
15
|
|
|
class EntryFactory |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @var ProjectConfig |
20
|
|
|
*/ |
21
|
|
|
protected $config; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var DeploystrategyFactory |
25
|
|
|
*/ |
26
|
|
|
protected $deploystrategyFactory; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var ParserFactoryInterface |
30
|
|
|
*/ |
31
|
|
|
protected $parserFactory; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param ProjectConfig $config |
35
|
|
|
* @param DeploystrategyFactory $deploystrategyFactory |
36
|
|
|
* @param ParserFactoryInterface $parserFactory |
37
|
|
|
*/ |
38
|
7 |
|
public function __construct( |
39
|
|
|
ProjectConfig $config, |
40
|
|
|
DeploystrategyFactory $deploystrategyFactory, |
41
|
|
|
ParserFactoryInterface $parserFactory |
42
|
|
|
) { |
43
|
7 |
|
$this->config = $config; |
44
|
7 |
|
$this->deploystrategyFactory = $deploystrategyFactory; |
45
|
7 |
|
$this->parserFactory = $parserFactory; |
46
|
7 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param PackageInterface $package |
50
|
|
|
* @param string $packageSourceDirectory |
51
|
|
|
* @return Entry |
52
|
|
|
*/ |
53
|
1 |
|
public function make(PackageInterface $package, $packageSourceDirectory) |
54
|
|
|
{ |
55
|
1 |
|
$entry = new Entry(); |
56
|
1 |
|
$entry->setPackageName($package->getName()); |
57
|
|
|
|
58
|
1 |
|
$strategy = $this->deploystrategyFactory->make($package, $packageSourceDirectory); |
59
|
1 |
|
$mappingParser = $this->parserFactory->make($package, $packageSourceDirectory); |
60
|
|
|
|
61
|
1 |
|
$strategy->setMappings($mappingParser->getMappings()); |
62
|
1 |
|
$entry->setDeployStrategy($strategy); |
63
|
|
|
|
64
|
1 |
|
return $entry; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|