1 | <?php |
||
35 | class OccRunner { |
||
36 | /** |
||
37 | * @var Locator $locator |
||
38 | */ |
||
39 | protected $locator; |
||
40 | |||
41 | /** |
||
42 | * @var bool |
||
43 | */ |
||
44 | protected $canUseProcess; |
||
45 | |||
46 | /** |
||
47 | * |
||
48 | * @param Locator $locator |
||
49 | * @param bool $canUseProcess |
||
50 | */ |
||
51 | 2 | public function __construct(Locator $locator, $canUseProcess){ |
|
55 | |||
56 | /** |
||
57 | * @param bool $canUseProcess |
||
58 | */ |
||
59 | public function setCanUseProcess($canUseProcess){ |
||
62 | |||
63 | /** |
||
64 | * @param $command |
||
65 | * @param array $args |
||
66 | * @param bool $asJson |
||
67 | * @return string |
||
68 | */ |
||
69 | 2 | public function run($command, $args = [], $asJson = false){ |
|
92 | |||
93 | /** |
||
94 | * @param $command |
||
95 | * @param array $args |
||
96 | * @return mixed |
||
97 | */ |
||
98 | 5 | public function runJson($command, $args = []){ |
|
109 | |||
110 | /** |
||
111 | * @param $command |
||
112 | * @param $args |
||
113 | * @return string |
||
114 | */ |
||
115 | protected function runAsRequest($command, $args){ |
||
116 | $application = $this->getApplication(); |
||
117 | $client = new Client(); |
||
118 | $endpointBase = $application->getEndpoint(); |
||
119 | $params = [ |
||
120 | 'timeout' => 0, |
||
121 | 'json' => [ |
||
122 | 'token' => $application->getAuthToken(), |
||
123 | 'params'=> $args |
||
124 | ] |
||
125 | ]; |
||
126 | |||
127 | // Skip SSL validation for localhost only as localhost never has a valid cert |
||
128 | if (preg_match('/^https:\/\/localhost\/.*/i', $endpointBase)){ |
||
129 | $params['verify'] = false; |
||
130 | } |
||
131 | |||
132 | $request = $client->createRequest( |
||
133 | 'POST', |
||
134 | $endpointBase . $command, |
||
135 | $params |
||
136 | ); |
||
137 | |||
138 | $response = $client->send($request); |
||
139 | $responseBody = $response->getBody()->getContents(); |
||
140 | return $responseBody; |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * @return mixed |
||
145 | */ |
||
146 | protected function getApplication(){ |
||
151 | |||
152 | /** |
||
153 | * @param $cmdLine |
||
154 | * @return string |
||
155 | */ |
||
156 | protected function runAsProcess($cmdLine){ |
||
168 | } |
||
169 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.