/** * For development environment, append the timestamp of static files like * style sheets, javascripts and so on as query string to the file path. This * will prevent the browser caching the file for the current session without * forcing a reload manually. * * @param string * A public file path, like "/stylesheets/screen.css". * * @return string * In development env, returns the file path but with the file timestamp * appended as query string. Otherwise the path will be returned as it is. * * Example: * "/stylesheets/screen.css" => "/stylesheets/screen.css?t=1263199885" */ function with_timestamp_param($static_file) { if (is_development()) { $full_path_to_static_file = PUBLIC_DIR . DS . $static_file; if (file_exists($full_path_to_static_file)) { return $static_file . '?t=' . filemtime($full_path_to_static_file); } } return $static_file; }
protected function beforeDeliver() { $this->sender = Config::get('app.ini', 'mailer.default_from_address'); $this->addRecipient(Config::get('app.ini', 'mailer.default_to_address')); if (is_development()) { //$this->sender = Config::get('development.ini', 'mailer.default_from_address'); //$this->addRecipient(Config::get('development.ini', 'mailer.default_to_address')); $this->deliveryType = self::DELIVERY_TYPE_LOCAL_FOLDER; $this->mailFolder = TMP_DIR; } }
public static function handleException(Exception $exception) { // Log exception $logger = Application::instance()->logger(); if ($logger !== null) { $msg = sprintf("%s: %s", get_class($exception), $exception->getMessage()); try { $logger->error($msg); } catch (Exception $e) { // Ignore exception, it will be handled next time } } // Mail exception $errorsMailer = new ErrorsMailer(); try { $errorsMailer->deliverErrorMail($exception); } catch (Exception $e) { // Ignore exception, it will be handled next time } // Render exception for development and show 500 page in production try { if (is_development()) { $format = is_cli() ? 'txt' : 'html'; $view_template = sprintf('errors/exception.%s.php', $format); $request = new Request(); $view = new View(APP_VIEWS_DIR, $view_template, array('exception' => $exception, 'request' => $request)); $response = new Response(); $response->statusCode = 500; $response->body = $view->render(); $response->send(); } else { if (!is_cli()) { $view = new View(PUBLIC_DIR, '500.html'); $response = new Response(); $response->statusCode = 500; $response->body = $view->render(); $response->send(); } } } catch (Exception $e) { echo $e->getMessage(); } exit; }