Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DeployManager.php
Go to the documentation of this file.
1 <?php
10 
11 
12 use Composer\IO\IOInterface;
15 
17 {
21  protected $packages = array();
22 
26  protected $io;
27 
33  protected $sortPriority = array();
34 
43  private $highPriority = [
44  'magento/magento2-base' => 10
45  ];
46 
47  public function __construct(IOInterface $io)
48  {
49  $this->io = $io;
50  }
51 
52  public function addPackage(Entry $package)
53  {
54  $this->packages[] = $package;
55  }
56 
57  public function setSortPriority($priorities)
58  {
59  $this->sortPriority = $priorities;
60  }
61 
70  protected function sortPackages()
71  {
72  usort(
73  $this->packages,
74  function ($a, $b) {
75  $aPriority = $this->getPackagePriority($a);
76  $bPriority = $this->getPackagePriority($b);
77  if ($aPriority == $bPriority) {
78  return 0;
79  }
80  return ($aPriority > $bPriority) ? -1 : 1;
81  }
82  );
83 
84  return $this->packages;
85  }
86 
87  public function doDeploy()
88  {
89  $this->sortPackages();
90 
92  foreach ($this->packages as $package) {
93  if ($this->io->isDebug()) {
94  $this->io->write('start magento deploy for ' . $package->getPackageName());
95  }
96  try {
97  $package->getDeployStrategy()->deploy();
98  } catch (\ErrorException $e) {
99  if ($this->io->isDebug()) {
100  $this->io->write($e->getMessage());
101  }
102  }
103  }
104  }
105 
112  private function getPackagePriority(Entry $package)
113  {
114  $result = 100;
115  $maxPriority = max(array_merge($this->sortPriority, [100, 101]));
116 
117  if (isset($this->highPriority[$package->getPackageName()])) {
118  $packagePriority = $this->highPriority[$package->getPackageName()];
119  $result = intval($maxPriority) + intval($packagePriority);
120  } elseif (isset($this->sortPriority[$package->getPackageName()])) {
121  $result = $this->sortPriority[$package->getPackageName()];
122  } elseif ($package->getDeployStrategy() instanceof Copy) {
123  $result = 101;
124  }
125 
126  return $result;
127  }
128 
129 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
Definition: Entry.php:12