/** * * Overrides the general Solar_App setup so that we don't need a * database connection. This is because we want the simplest * possible hello-world example. * * Thanks, Clay Loveless, for suggesting this. * * @return void * */ protected function _setup() { // register a Solar_User object if not already. // this will trigger the authentication process. if (!Solar_Registry::exists('user')) { Solar_Registry::set('user', Solar::factory('Solar_User')); } // set the layout title $this->layout_head['title'] = get_class($this); }
/** * * Post-construction tasks to complete object construction. * * @return void * */ protected function _postConstruct() { parent::_postConstruct(); setcookie($this->_config['cookie'], null, 1); $this->_session = Solar::factory('Solar_Session', array('class' => 'Solar_Log_Adapter_Chromephp')); if (Solar_Registry::exists('chromephp_data')) { $this->_obj = Solar_Registry::get('chromephp_data'); } else { $this->_obj = new StdClass(); $this->_obj->data = array(); $this->_obj->backtrace = array(); $this->_obj->labels = array(); $this->_obj->version = $this->_config['version']; Solar_Registry::set('chromephp_data', $this->_obj); } }
/** * * Registers an object under a unique name. * * @param string $name The name under which to register the object. * * @param object|string $spec The registry specification. * * @param mixed $config If lazy-loading, use this as the config. * * @return void * * @todo Localize these errors. * */ public static function set($name, $spec, $config = null) { if (Solar_Registry::exists($name)) { // name already exists in registry $class = get_class(Solar_Registry::$_obj[$name]); throw Solar::exception('Solar_Registry', 'ERR_REGISTRY_NAME_EXISTS', "Object with '{$name}' of class '{$class}' already in registry", array('name' => $name, 'class' => $class)); } // register as an object, or as a class and config? if (is_object($spec)) { // directly register the object Solar_Registry::$_obj[$name] = $spec; } elseif (is_string($spec)) { // register a class and config for lazy loading Solar_Registry::$_obj[$name] = array($spec, $config); } else { throw Solar::exception('Solar_Registry', 'ERR_REGISTRY_FAILURE', 'Please pass an object, or a class name and a config array', array()); } }
/** * * Runs a series of callbacks using call_user_func_array(). * * The callback array looks like this: * * {{code: php * $callbacks = array( * // static method call * array('Class_Name', 'method', $param1, $param2, ...), * * // instance method call on a registry object * array('registry-key', 'method', $param1, $param2, ...), * * // instance method call * array($object, 'method', $param1, $param2, ...), * * // function call * array(null, 'function', $param1, $param2, ...), * * // file include, as in previous versions of Solar * 'path/to/file.php', * ); * }} * * @param array $callbacks The array of callbacks. * * @return void * * @see start() * * @see stop() * */ public static function callbacks($callbacks) { foreach ((array) $callbacks as $params) { // include a file as in previous versions of Solar if (is_string($params)) { Solar_File::load($params); continue; } // $spec is an object instance, class name, or registry key $spec = array_shift($params); if (!is_object($spec)) { // not an object, so treat as a class name ... $spec = (string) $spec; // ... unless it's a registry key. if (Solar_Registry::exists($spec)) { $spec = Solar_Registry::get($spec); } } // the method to call on $spec $func = array_shift($params); // make the call if ($spec) { call_user_func_array(array($spec, $func), $params); } else { call_user_func_array($func, $params); } } }
/** * * Sets up the Solar_App environment. * * Registers 'sql', 'user', and 'content' objects, and sets the * layout title to the class name. * * @return void * */ protected function _setup() { // register a Solar_Sql object if not already if (!Solar_Registry::exists('sql')) { Solar_Registry::set('sql', Solar::factory('Solar_Sql')); } // register a model catalog if not already if (!Solar_Registry::exists('model_catalog')) { Solar_Registry::set('model_catalog', Solar::factory('Solar_Sql_Model_Catalog')); } // register a Solar_User object if not already. // this will trigger the authentication process. if (!Solar_Registry::exists('user')) { Solar_Registry::set('user', Solar::factory('Solar_User')); } // set the layout title $this->layout_head['title'] = get_class($this); // retain the model catalog $this->_model = Solar_Registry::get('model_catalog'); }
/** * * Partial layout template for the user authentication div. * * @category Solar * * @package Solar_App * * @author Paul M. Jones <*****@*****.**> * * @license http://opensource.org/licenses/bsd-license.php BSD * * @version $Id: _auth.php 3689 2009-04-17 00:51:15Z pmjones $ * */ if (Solar_Registry::exists('user')) { ?> <div id="auth"> <?php if (Solar_Registry::get('user')->auth->isValid()) { ?> <p> <?php echo $this->getText('TEXT_AUTH_USERNAME'); ?> <br /> <strong><?php echo $this->escape(Solar_Registry::get('user')->auth->handle); ?> </strong> </p>
/** * Checks if the registered JForg_Dodb exists, sets some vars * * @return void * @author Bahtiar Gadimov <*****@*****.**> */ protected function _postConfig() { if (Solar_Registry::exists($this->_config['dodb'])) { $this->_dodb = Solar_Registry::get($this->_config['dodb']); } else { throw $this->_exception('NO_DOCUMENT_ADAPTER'); } if (isset($this->_config['sheme'])) { if (!is_array($this->_config['sheme'])) { throw $this->_exception('SHEME_SHOULD_BE_ARRAY'); } $this->_sheme = $this->_config['sheme']; } if (isset($this->_config['final'])) { if (!is_bool($this->_config['final'])) { throw $this->_exception('FINAL_SHOULD_BE_BOOL'); } $this->_final = $this->_config['final']; } }