/**
  * Handler xhr response data and add debug for it
  * @param Event $event
  */
 public function handlerXhrResponse(Event $event)
 {
     /** @var Response $response */
     $response = $event->sender;
     $records = Profiler::getInstance()->getProfileData();
     $this->_writeNormalRequest($records);
     $body = $response->getBody();
     if ($t = json_decode($body, true)) {
         $t['debug'] = self::$_records;
         $body = json_encode($t);
     }
     $response->setBody($body);
 }
 public function executeUpdate($query, array $params = array(), array $types = array())
 {
     try {
         $begin = $this->getDebugSnapshot();
         if ($params) {
             $stmt = $this->prepare($query);
             if ($types) {
                 $this->_bindTypedValues($stmt, $params, $types);
                 $stmt->execute();
             } else {
                 $stmt->execute($params);
             }
             $result = $stmt->rowCount();
         } else {
             $result = $this->exec($query);
         }
         $end = $this->getDebugSnapshot();
         Profiler::logSqlQueries($query, $begin, $end, $params);
     } catch (\Exception $ex) {
         throw new Exception("An exception occurred while executing '{$query}'" . ($params ? ' with params ' . json_encode($params, JSON_UNESCAPED_UNICODE) : ''), 500, $ex);
     }
     return $result;
 }
 public static function enable()
 {
     Profiler::init();
 }