public function __construct() { $ret = parent::__construct(); $config = Pfw_Config::getConfig(); $this->assignSiteTitle($config['site_title']); $this->setupPaths(); return $ret; }
public function __construct() { parent::__construct(); global $_PATHS, $_ENVIRONMENT; $_PATHS['conf'] = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . "test" . DIRECTORY_SEPARATOR . "conf"; $_ENVIRONMENT = isset($_ENVIRONMENT) ? $_ENVIRONMENT : "test"; Pfw_Config::reset(); Pfw_Config::init($_ENVIRONMENT); }
public function open($save_path, $session_name) { $this->config = Pfw_Config::get('session'); $db_route_name = $this->config['handler']['db_route_name']; $db_router = new Pfw_Db_Router_Standard($db_route_name); $db_route = $db_router->getWriteRoute(); $this->db = Pfw_Db::factory($db_route, true); $this->sessions = array(); $this->db_table = isset($this->config['handler']['db_table']) ? $this->config['handler']['db_table'] : self::DEFAULT_DB_TABLE; return true; }
/** * Starts a new session. Generally happens in prj_startup.php. * Should happen once per request. */ public static function start() { if (self::isStarted()) { return false; } $config = Pfw_Config::getConfig(); if (!isset($config['session'])) { $config['session'] = array(); } // maybe accept ini params in args and set here? // ... if (ini_get('session.auto_start')) { // reset session if autostarted in ini error_log("A session handler is configured, but session was autostarted in " . "ini with session.auto_start, resetting for normal session handling."); session_write_close(); } if (isset($config['session']['handler_class'])) { self::setupHandler($config['session']['handler_class']); } else { if (isset($config['session']['save_path'])) { session_save_path($config['session']['save_path']); } } if (isset($config['session']['lifetime_s'])) { $lifetime_s = intval($config['session']['lifetime_s']); ini_set('session.cookie_lifetime', $lifetime_s); if (isset($config['session']['renew']) and false == $config['session']['renew']) { // not renewing, absolute max lifetime self::$is_renewing = false; } else { // renewing self::$is_renewing = true; } } session_start(); // if you're going to mess with the cookies, its gotta be // after the session as started if (self::$is_renewing) { self::renew($lifetime_s); } self::$initialized = true; }
/** * Returns an instance of the local cache driver * * @return Pfw_Cache|null instance of a Pfw_Cache object or null if none * is configured */ public static function getInstance() { if (!is_null(self::$instance)) { return self::$instance; } if (null == ($local_cache = Pfw_Config::get('local_cache'))) { return null; } if (is_array($local_cache)) { $class = $local_cache['class']; unset($local_cache['class']); $options = $local_cache; } else { $class = $local_cache; $options = array(); } Pfw_Loader::loadClass($class); self::$instance = new $class($options); return self::$instance; }
<?php global $_picnic_path; $curr_dir = dirname(__FILE__); // include the environment file require dirname($curr_dir) . '/conf/environment.php'; // include the paths file require "{$curr_dir}/prj_paths.php"; // get our project lib file $_prj_lib_path = rtrim(rtrim($_PATHS['lib'], '/'), "\\"); // begin by setting our project paths as highest priority $_inc_path = $_prj_lib_path; // add project third party paths $_inc_path .= PATH_SEPARATOR . $_prj_lib_path . DIRECTORY_SEPARATOR . "ThirdParty"; // if picnic path is set explicitly, use it, otherwise we assume its already in the include path if (isset($_picnic_path)) { // add picnic path $_inc_path .= PATH_SEPARATOR . $_picnic_path; // add picnic third party path $_inc_path .= PATH_SEPARATOR . $_picnic_path . DIRECTORY_SEPARATOR . "ThirdParty"; } // setup project include path for our project set_include_path($_inc_path . PATH_SEPARATOR . get_include_path()); require 'Pfw/Startup/Base.php'; require "{$curr_dir}/prj_global_require.php"; // initialize the config Pfw_Config::init(); date_default_timezone_set(Pfw_Config::get('default_timezone'));
public function getReadRoute() { $config = Pfw_Config::getConfig(); $route_name = $this->getRouteName(); return $config['database'][$route_name]['params']; }
public function testOptions() { Pfw_Config::setConfig(array('local_cache' => array('class' => 'Pfw_Cache_Stub', 'stuff' => 'ok'))); $this->assertEquals(array('stuff' => 'ok'), Pfw_Cache_Local::getInstance()->options); }
public function testReset() { Pfw_Config::init(); $conf = Pfw_Config::getConfig(); $this->assertEquals('My Web Host', Pfw_Config::get('webhost')); Pfw_Config::setConfig(array('test' => 'ok')); $this->assertEquals('ok', Pfw_Config::get('test')); $this->assertEquals(null, Pfw_Config::get('webhost')); Pfw_Config::reset(); Pfw_Config::init(); $this->assertEquals(null, Pfw_Config::get('test')); $this->assertEquals('My Web Host', Pfw_Config::get('webhost')); }
/** * Gets the entire config array. * * @return array the configuration array */ public static function getConfig() { if (is_null(self::$config)) { self::$config = array(); } return self::$config; }