Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DependencyReadinessCheck.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Setup\Model;
7 
14 
19 {
23  private $composerJsonFinder;
24 
28  private $directoryList;
29 
33  private $requireUpdateDryRunCommand;
34 
38  private $file;
39 
43  private $magentoComposerApplication;
44 
53  public function __construct(
54  ComposerJsonFinder $composerJsonFinder,
55  DirectoryList $directoryList,
56  File $file,
57  MagentoComposerApplicationFactory $composerAppFactory
58  ) {
59  $this->composerJsonFinder = $composerJsonFinder;
60  $this->directoryList = $directoryList;
61  $this->file = $file;
62  $this->requireUpdateDryRunCommand = $composerAppFactory->createRequireUpdateDryRunCommand();
63  $this->magentoComposerApplication = $composerAppFactory->create();
64  }
65 
73  public function runReadinessCheck(array $packages)
74  {
75  $composerJson = $this->composerJsonFinder->findComposerJson();
76  $this->file->copy($composerJson, $this->directoryList->getPath(DirectoryList::VAR_DIR) . '/composer.json');
77  $workingDir = $this->directoryList->getPath(DirectoryList::VAR_DIR);
78  try {
79  foreach ($packages as $package) {
80  if (strpos($package, 'magento/product-enterprise-edition') !== false) {
81  $this->magentoComposerApplication->runComposerCommand(
82  [
83  'command' => 'remove',
84  'packages' => ['magento/product-community-edition'],
85  '--no-update' => true
86  ],
87  $workingDir
88  );
89  }
90  }
91  $this->requireUpdateDryRunCommand->run($packages, $workingDir);
92  return ['success' => true];
93  } catch (\RuntimeException $e) {
94  $message = str_replace(PHP_EOL, '<br/>', htmlspecialchars($e->getMessage()));
95  return ['success' => false, 'error' => $message];
96  }
97  }
98 }
$message
__construct(ComposerJsonFinder $composerJsonFinder, DirectoryList $directoryList, File $file, MagentoComposerApplicationFactory $composerAppFactory)