CompactDeploy.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Strategy;
  7. use Magento\Deploy\Package\PackagePool;
  8. use Magento\Deploy\Package\Package;
  9. use Magento\Deploy\Process\Queue;
  10. /**
  11. * Compact deployment strategy implementation
  12. */
  13. class CompactDeploy implements StrategyInterface
  14. {
  15. /**
  16. * Package pool object
  17. *
  18. * @var PackagePool
  19. */
  20. private $packagePool;
  21. /**
  22. * Deployment queue
  23. *
  24. * @var Queue
  25. */
  26. private $queue;
  27. /**
  28. * CompactDeploy constructor
  29. *
  30. * @param PackagePool $packagePool
  31. * @param Queue $queue
  32. */
  33. public function __construct(
  34. PackagePool $packagePool,
  35. Queue $queue
  36. ) {
  37. $this->packagePool = $packagePool;
  38. $this->queue = $queue;
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. public function deploy(array $options)
  44. {
  45. $packages = $this->packagePool->getPackagesForDeployment($options);
  46. foreach ($packages as $package) {
  47. /* @var Package $package */
  48. // set closest ancestor package as parent
  49. $parentPackages = $package->getParentPackages();
  50. $package->setParent(array_pop($parentPackages));
  51. if (!$package->isVirtual()) {
  52. // flag is required to enable "Package Map files" post-processor
  53. /* @see \Magento\Deploy\Package\Processor\PostProcessor\Map */
  54. $package->setParam('build_map', true);
  55. }
  56. // set all parent packages as dependencies for current package deployment task
  57. $this->queue->add($package, $package->getParentPackages());
  58. }
  59. $this->queue->process();
  60. return $packages;
  61. }
  62. }