コード例 #1
0
 /**
  * {@inheritdoc}
  *
  * @return \Psr\Http\Message\ResponseInterface|DockerRawStream
  */
 public function attach($id, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $response = parent::attach($id, $parameters, $fetch);
     if ($response->getStatusCode() == 200 && DockerRawStream::HEADER == $response->getHeaderLine('Content-Type')) {
         if ($fetch == self::FETCH_STREAM) {
             return new DockerRawStream($response->getBody());
         }
     }
     return $response;
 }
コード例 #2
0
ファイル: ContainerManager.php プロジェクト: plesk/docker-php
 /**
  * @inheritDoc
  *
  * @return \Psr\Http\Message\ResponseInterface|DockerRawStream|string[][]
  */
 public function logs($id, $parameters = [], $fetch = self::FETCH_OBJECT)
 {
     $response = parent::logs($id, $parameters, $fetch);
     if ($response->getStatusCode() == 200) {
         if ($fetch == self::FETCH_STREAM) {
             return new DockerRawStream($response->getBody());
         }
         if ($fetch == self::FETCH_OBJECT) {
             $dockerRawStream = new DockerRawStream($response->getBody());
             $logs = ['stdout' => [], 'stderr' => []];
             $dockerRawStream->onStdout(function ($logLine) use(&$logs) {
                 $logs['stdout'][] = $logLine;
             });
             $dockerRawStream->onStderr(function ($logLine) use(&$logs) {
                 $logs['stderr'][] = $logLine;
             });
             $dockerRawStream->wait();
             return $logs;
         }
     }
     return $response;
 }