public static function handleException($exc) { if ($exc instanceof Tuffy_Debug_Exit) { exit; } if (!$exc instanceof Exception) { $exc = new Exception(var_export($exc)); } $log = self::getLog(TRUE); $tuffyLoaded = class_exists('Tuffy', FALSE); if ($tuffyLoaded && !Tuffy::setting('debug')) { $callback = $tuffyLoaded ? Tuffy::setting('errorHandlerProduction', self::PRODUCTION_HANDLER) : self::PRODUCTION_HANDLER; } else { $callback = $tuffyLoaded ? Tuffy::setting('errorHandlerDev', self::DEV_HANDLER) : self::DEV_HANDLER; } call_user_func($callback, $exc, $log); return TRUE; }
/** * Decides whether to configure the module or not. If the configuration * setting configure.Module_Name is TRUE, it will configure it. * * @param string The module to check the settings for. */ public function shouldConfigure($module) { return (bool) Tuffy::setting("modules.{$module}"); }
/** * Adds a new warning message to the debug log, if the $debug setting is * TRUE. * * @param string $title A label for the debug message describing its data. * @param string $data The data to display. * @param int $skipExtra The number of stack frames to skip when assigning * this message a traceback. */ public static function warn($title, $data, $skipExtra = 0) { if (Tuffy::setting('debug')) { $stack = array_slice(Tuffy_Debug::getBacktrace(), 1 + $skipExtra); return Tuffy_Debug::addMessage(new Tuffy_Debug_Message($title, $data, $stack, Tuffy_Debug::PROBLEM)); } }
/** * Executes the statement. * * @param array $params Parameters to bind before executing the statement. * You can use this to simplify running several sequential inserts. */ public function execute($params = NULL) { $debug = Tuffy::setting('debug'); if ($params) { $this->bind($params); } if ($debug) { ob_start(); $this->debugDumpParams(); $idx = Tuffy::debug("Query", ob_get_clean()); } parent::execute(); if ($debug) { Tuffy_Debug::completeEvent($idx); } }
date_default_timezone_set(Tuffy::setting('timezone')); } unset($tuffyTimezone); if (Tuffy::setting('useSessions')) { session_start(); if (Tuffy::setting('debug')) { Tuffy_Debug::restoreLogFromSession(); Tuffy::debug("Session " . session_id(), $_SESSION); } } if ($libraryPath = Tuffy::setting('libraryPath')) { $tuffyAppLoader = new Tuffy_Loader(Tuffy::setting('appName'), Tuffy_Util::interpretPath($libraryPath)); $tuffyAppLoader->register(); } unset($libraryPath); foreach (Tuffy::setting('initializers', array()) as $init) { call_user_func($init); } // 7. Here are a couple of completely non-namespaced utility functions // that are just too useful not to have. /** * If the $key exists in $array, returns the value stored therein. Otherwise, * returns $default. * * @param array $array The array to check. * @param mixed $key The key to search for. * @param mixed $default The value to return if the key does not exist. * (It defaults to NULL.) */ function maybe($array, $key, $default = NULL) {
/** * Registers a default set of template functions, filter, and globals * to the shared template environment. */ public static function registerDefaults() { // General // hash is very useful when creating ID's for ephemeral objects self::addFunction('hash', 'spl_object_hash'); // Tuffy self::addFunction('Tuffy::url'); self::addFunction('Tuffy::getFlashes'); // Tuffy_Debug self::addGlobal('DEBUG', Tuffy::setting('debug')); self::addFunction('getDebugLog', 'Tuffy_Debug::getLog'); }