StandardDeploy.php 1.6 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. * Standard deployment strategy implementation
  12. */
  13. class StandardDeploy 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. * StandardDeploy 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. $deployedPackages = [];
  46. $packages = $this->packagePool->getPackagesForDeployment($options);
  47. foreach ($packages as $package) {
  48. /** @var Package $package */
  49. if ($package->isVirtual()) {
  50. // skip packages which can not be referenced directly from web ...
  51. continue;
  52. }
  53. // ... and aggregate files from ancestors for others
  54. $package->aggregate();
  55. $deployedPackages[] = $package;
  56. }
  57. foreach ($deployedPackages as $package) {
  58. $this->queue->add($package);
  59. }
  60. $this->queue->process();
  61. return $deployedPackages;
  62. }
  63. }