Esempio n. 1
0
 /**
  * Mount profiler panel to response (if possible).
  *
  * @param Request  $request Server request instance.
  * @param Response $response
  * @param float    $started Time when profiler was activated.
  * @param float    $elapsed Elapsed time.
  * @return Response
  */
 protected function mountPanel(Request $request, Response $response, $started = 0.0, $elapsed = 0.0)
 {
     if (!$response->getBody()->isWritable()) {
         //We can't write to the stream
         return $response;
     }
     if (!empty($response->getHeaderLine('Content-Type'))) {
         if (strpos($response->getHeaderLine('Content-Type'), 'html') === false) {
             //We can only write to responses when content type does not specified or responses
             //with html related content type
             return $response;
         }
     }
     $response->getBody()->write($this->view->render('profiler:panel', ['profiler' => $this, 'container' => $this->container, 'request' => $request, 'response' => $response, 'started' => $started, 'elapsed' => $elapsed]));
     return $response;
 }