MagentoComposerApplicationFactory.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Composer;
  7. use Magento\Composer\InfoCommand;
  8. use Magento\Composer\MagentoComposerApplication;
  9. use Magento\Composer\RequireUpdateDryRunCommand;
  10. use Magento\Framework\App\Filesystem\DirectoryList;
  11. class MagentoComposerApplicationFactory
  12. {
  13. /**
  14. * @var string
  15. */
  16. private $pathToComposerHome;
  17. /**
  18. * @var string
  19. */
  20. private $pathToComposerJson;
  21. /**
  22. * Constructor
  23. *
  24. * @param ComposerJsonFinder $composerJsonFinder
  25. * @param DirectoryList $directoryList
  26. */
  27. public function __construct(ComposerJsonFinder $composerJsonFinder, DirectoryList $directoryList)
  28. {
  29. $this->pathToComposerJson = $composerJsonFinder->findComposerJson();
  30. $this->pathToComposerHome = $directoryList->getPath(DirectoryList::COMPOSER_HOME);
  31. }
  32. /**
  33. * Creates MagentoComposerApplication instance
  34. *
  35. * @return MagentoComposerApplication
  36. */
  37. public function create()
  38. {
  39. return new MagentoComposerApplication($this->pathToComposerHome, $this->pathToComposerJson);
  40. }
  41. /**
  42. * Creates InfoCommand instance
  43. *
  44. * @return InfoCommand
  45. */
  46. public function createInfoCommand()
  47. {
  48. return new InfoCommand($this->create());
  49. }
  50. /**
  51. * Creates RequireUpdateDryRunCommand instance
  52. *
  53. * @return RequireUpdateDryRunCommand
  54. */
  55. public function createRequireUpdateDryRunCommand()
  56. {
  57. return new RequireUpdateDryRunCommand($this->create(), $this->createInfoCommand());
  58. }
  59. }