@@ -63,11 +63,15 @@ class MagentoComposerApplication
63
63
/**
64
64
* Constructs class
65
65
*
66
+ * @param string $pathToComposerHome
67
+ * @param string $pathToComposerJson
66
68
* @param Application $consoleApplication
67
69
* @param ConsoleArrayInputFactory $consoleArrayInputFactory
68
70
* @param BufferedOutput $consoleOutput
69
71
*/
70
72
public function __construct (
73
+ $ pathToComposerHome ,
74
+ $ pathToComposerJson ,
71
75
Application $ consoleApplication = null ,
72
76
ConsoleArrayInputFactory $ consoleArrayInputFactory = null ,
73
77
BufferedOutput $ consoleOutput = null
@@ -76,56 +80,35 @@ public function __construct(
76
80
$ this ->consoleArrayInputFactory = $ consoleArrayInputFactory ? $ consoleArrayInputFactory
77
81
: new ConsoleArrayInputFactory ();
78
82
$ this ->consoleOutput = $ consoleOutput ? $ consoleOutput : new BufferedOutput ();
79
- }
80
83
81
- /**
82
- * Sets composer environment config
83
- *
84
- * @param string $pathToComposerHome
85
- * @param string $pathToComposerJson
86
- */
87
- public function setConfig ($ pathToComposerHome , $ pathToComposerJson )
88
- {
89
84
$ this ->composerJson = $ pathToComposerJson ;
90
85
$ this ->composerHome = $ pathToComposerHome ;
91
86
92
87
putenv ('COMPOSER_HOME= ' . $ pathToComposerHome );
93
88
94
89
$ this ->consoleApplication ->setAutoExit (false );
95
- $ this ->configIsSet = true ;
96
-
97
90
}
98
91
99
92
/**
100
- * Returns composer object
93
+ * Creates composer object
101
94
*
102
95
* @return \Composer\Composer
103
96
* @throws \Exception
104
97
*/
105
- public function getComposer ()
98
+ public function createComposer ()
106
99
{
107
- if (!$ this ->configIsSet ) {
108
- throw new \Exception ('Please call setConfig method to configure composer ' );
109
- }
110
-
111
100
return ComposerFactory::create (new BufferIO (), $ this ->composerJson );
112
-
113
101
}
114
102
115
103
/**
116
104
* Runs composer command
117
105
*
118
106
* @param array $commandParams
119
107
* @return bool
120
- * @throws \Exception
121
108
* @throws \RuntimeException
122
109
*/
123
110
public function runComposerCommand (array $ commandParams )
124
111
{
125
- if (!$ this ->configIsSet ) {
126
- throw new \Exception ('Please call setConfig method to configure composer ' );
127
- }
128
-
129
112
$ this ->consoleApplication ->resetComposer ();
130
113
131
114
$ commandParams [self ::COMPOSER_WORKING_DIR ] = dirname ($ this ->composerJson );
0 commit comments