public function prepareAndSendValidResponse($arr) { $response = array('status' => array('code' => self::VALID_RESPONSE_CODE, 'message' => self::VALID_RESPONSE_STATUS), 'response' => $arr); // Log Valid Response $data = array('api_response' => serialize($response), 'upd_process_id' => 'BasePresenter::prepareAndSendValidResponse()'); $this->loggerService->updateLogVisit($this->lastLogItem->id, $data); // Send response $this->sendResponse(new \Nette\Application\Responses\JsonResponse($response)); }
public function shutdown($response) { parent::shutdown($response); if ($this->getHttpRequest()->getUrl()->path != '/healthy-check') { $elapsed = \Nette\Diagnostics\Debugger::timer('global'); // Log Valid Response $data = array('elapsed' => $elapsed, 'upd_process_id' => 'BasePresenter::shutdown()'); if ($this->lastLogItem) { $this->logger->updateLogVisit($this->lastLogItem->id, $data); } } }
/** * Translates the given string. * @param string message * @param int plural count * @return string translated string */ public function translate($message, $param1 = null, $param2 = null, $param3 = null) { $langFrom = $this->getLangFrom(); $langTo = $this->getLangTo(); // If languages are same or no languages given, return original message if ($langFrom == $langTo || !$langFrom || !$langTo || empty($message) || is_numeric($message)) { return sprintf($message, $param1, $param2, $param3); } else { // Fetch translated strings $translationsArray = $this->getTranslationsArray(); $stringsArray = $this->getStringsArray(); // Check for given message if is translated $messageTranslated = isset($translationsArray[$langFrom][md5($message)][$langTo]) ? $translationsArray[$langFrom][md5($message)][$langTo] : null; if (!empty($messageTranslated)) { $messageOut = sprintf($messageTranslated, $param1, $param2, $param3); } else { // The string should not be translated, please log where it is found! if (!$this->isUsedToTranslate($message)) { $this->logger->log('String that should not be translated found', 'DbTranslator', $this->httpRequest->getUrl(), $message); return sprintf($message, $param1, $param2, $param3); } // Check for given message if is in untranslated cache $messageCached = isset($stringsArray[md5($message)]) ? $stringsArray[md5($message)] : null; if (!empty($messageCached)) { $messageOut = sprintf($messageCached, $param1, $param2); } else { // String is not translated yet $messageOut = sprintf($message, $param1, $param2, $param3); $this->saveNonTranslatedString($message); } } return $messageOut; } }