示例#1
0
}
// 6. Configure the environment.
$tuffyTimezone = Tuffy::setting('timezone');
if ($tuffyTimezone !== NULL) {
    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.
 /**
  * Creates the default template loader. It will load templates from the
  * directory indicated by the `template.path` setting if defined,
  * otherwise it will use `TUFFY_APP_PATH/templates`.
  */
 public static function getDefaultLoader()
 {
     $templatePath = Tuffy_Util::interpretPath(Tuffy::setting('template.path', 'templates'));
     return new Twig_Loader_Filesystem($templatePath);
 }