public function loadResponse($id)
 {
     if (!isset($this->connectionData[$id])) {
         throw new \InvalidArgumentException('Tried to get response for invalid ID $id.');
     }
     $connectionData = $this->connectionData[$id];
     $action = $connectionData->getAction();
     if (empty($action)) {
         $this->log->error('Request type missing.');
         $connectionData->setNullResponse();
         return;
     }
     $fileNamePrefix = $this->getFileNamePrefix($connectionData);
     $fileExtension = $this->getFileExtension($connectionData);
     $queryString = $this->getQueryString($connectionData);
     $fileName = $this->getFileName($fileNamePrefix, md5($queryString), $fileExtension);
     if (!$this->hasFileNameChanged($id, $fileName)) {
         return;
     }
     $this->log->info("Trying to load file: {$fileName}");
     $fileContent = null;
     if (!($fileContent = @file_get_contents($fileName))) {
         throw new \Exception('File "' . $fileName . ' (original: ' . $fileNamePrefix . $queryString . $fileExtension . '" not found');
     }
     $response = FF::getInstance('Core\\Server\\Response', $fileContent, 200, 0, '');
     $connectionData->setResponse($response, $fileName);
 }
 public function loadResponse($id)
 {
     if (!isset($this->connectionData[$id])) {
         throw new \InvalidArgumentException('Tried to get response for invalid ID $id.');
     }
     $connectionData = $this->connectionData[$id];
     $action = $connectionData->getAction();
     if (empty($action)) {
         $this->log->error('Request type missing.');
         $connectionData->setNullResponse();
         return;
     }
     $fileName = $this->getFileName($connectionData);
     if (!$this->hasFileNameChanged($id, $fileName)) {
         return;
     }
     $this->log->info("Trying to load file: {$fileName}");
     $response = FF::getInstance('Core\\Server\\Response', file_get_contents($fileName), 200, 0, '');
     $connectionData->setResponse($response, $fileName);
 }
 private function logResult($response)
 {
     $httpCode = $response->getHttpCode();
     $curlError = $response->getConnectionError();
     if ($httpCode >= 400) {
         $this->log->error("Connection failed. HTTP code: {$httpCode}");
     } else {
         if ($httpCode == 0) {
             $this->log->error("Connection refused. cURL error: {$curlError}");
         } else {
             if (floor($httpCode / 100) == 2) {
                 // all successful status codes (2**)
                 $this->log->info("Request successful!");
             }
         }
     }
 }