本文整理汇总了PHP中Solar_Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Solar_Registry::set方法的具体用法?PHP Solar_Registry::set怎么用?PHP Solar_Registry::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solar_Registry
的用法示例。
在下文中一共展示了Solar_Registry::set方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
$this->_sql = Solar::factory('Solar_Sql', array('adapter' => 'Solar_Sql_Adapter_Sqlite', 'name' => ':memory:'));
// forcibly add sql to registry
Solar_Registry::set('sql', $this->_sql);
$cmd = "CREATE TABLE acl (" . " flag VARCHAR(10)," . " type CHAR(100)," . " name VARCHAR(255)," . " class_name VARCHAR(255)," . " action_name VARCHAR(255)," . " position VARCHAR(255)" . ")";
$this->_sql->query($cmd);
$dir = Solar_Class::dir('Test_Solar_Access_Adapter', '_support');
$lines = file_get_contents($dir . 'access.txt');
$rows = explode("\n", $lines);
$pos = 0;
foreach ($rows as $row) {
$row = trim($row);
// skip empty lines and comments
if (empty($row) || substr($row, 0, 1) == '#') {
continue;
}
$row = preg_replace('/[ \\t]{2,}/', ' ', $row);
$row = explode(' ', $row);
$data['flag'] = trim($row[0]);
$data['type'] = trim($row[1]);
$data['name'] = trim($row[2]);
$data['class_name'] = trim($row[3]);
$data['action_name'] = trim($row[4]);
$data['position'] = $pos;
$this->_sql->insert('acl', $data);
$pos++;
}
parent::setup();
}
示例2: _setup
/**
*
* 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);
}
示例3: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
parent::setup();
// set up an SQL connection
$this->_sql = Solar::factory('Solar_Sql', $this->_sql_config);
// set up a model catalog
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config);
// register the connection and catalog
Solar_Registry::set('sql', $this->_sql);
Solar_Registry::set('model_catalog', $this->_catalog);
}
示例4: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
parent::setup();
// set up an SQL connection
$this->_sql = Solar::factory('Solar_Sql', $this->_sql_config);
$this->_sql->setProfiling(true);
// set up a model catalog
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config);
// register the connection and catalog
Solar_Registry::set('sql', $this->_sql);
Solar_Registry::set('model_catalog', $this->_catalog);
// populate everything
$this->_populateAll();
}
示例5: preTest
/**
*
* Setup; runs before each test method.
*
*/
public function preTest()
{
parent::preTest();
// set up an SQL connection
$this->_sql = Solar::factory('Solar_Sql', $this->_sql_config);
$this->_sql->setProfiling(true);
// set up a model catalog
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config);
// register the connection and catalog
Solar_Registry::set('sql', $this->_sql);
Solar_Registry::set('model_catalog', $this->_catalog);
// fixture to populate tables
$this->_fixture = Solar::factory('Fixture_Solar_Sql_Model');
}
示例6: _postConstruct
/**
*
* 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);
}
}
示例7: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
parent::setup();
// set up an SQL connection
$this->_sql = Solar::factory('Solar_Sql', $this->_sql_config);
$this->_sql->setProfiling(true);
// set up a model catalog
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config);
// register the connection and catalog
Solar_Registry::set('sql', $this->_sql);
Solar_Registry::set('model_catalog', $this->_catalog);
// set the class name for relateds
$len = strlen('Test_');
$this->_class = substr(get_class($this), $len);
// populate everything
$this->_populateAll();
}
示例8: preTest
/**
*
* Setup; runs before each test method.
*
*/
public function preTest()
{
parent::preTest();
// set up an SQL connection
$this->_sql = Solar::factory('Solar_Sql', $this->_sql_config);
// set up a model catalog
$this->_catalog = Solar::factory('Solar_Sql_Model_Catalog', $this->_catalog_config);
// register the connection and catalog
Solar_Registry::set('sql', $this->_sql);
Solar_Registry::set('model_catalog', $this->_catalog);
// fixture to populate tables
$this->_fixture = Solar::factory('Fixture_Solar_Sql_Model');
$this->_fixture->setup();
// preload all models to get discovery out of the way
$this->_catalog->users;
$this->_catalog->prefs;
$this->_catalog->areas;
$this->_catalog->nodes;
$this->_catalog->metas;
$this->_catalog->tags;
$this->_catalog->taggings;
$this->_catalog->comments;
$this->_sql->setProfiling(true);
}
示例9: start
/**
*
* Starts Solar: loads configuration values and and sets up the environment.
*
* Note that this method is overloaded; you can pass in different
* value types for the $config parameter.
*
* * `null|false` -- This will not load any new configuration values;
* you will get only the default [[Solar::$config]] array values defined
* in the Solar class.
*
* * `string` -- The string is treated as a path to a Solar.config.php
* file; the return value from that file will be used for [[Solar_Config::load()]].
*
* * `array` -- This will use the passed array for the [[Solar_Config::load()]]
* values.
*
* * `object` -- The passed object will be cast as an array, and those
* values will be used for [[Solar_Config::load()]].
*
* Here are some examples of starting with alternative configuration parameters:
*
* {{code: php
* require_once 'Solar.php';
*
* // don't load any config values at all
* Solar::start();
*
* // point to a config file (which returns an array)
* Solar::start('/path/to/another/config.php');
*
* // use an array as the config source
* $config = array(
* 'Solar' => array(
* 'ini_set' => array(
* 'error_reporting' => E_ALL,
* ),
* ),
* );
* Solar::start($config);
*
* // use an object as the config source
* $config = new StdClass;
* $config->Solar = array(
* 'ini_set' => array(
* 'error_reporting' => E_ALL,
* ),
* );
* Solar::start($config);
* }}
*
* @param mixed $config The configuration source value.
*
* @return void
*
* @see Solar::cleanGlobals()
*
*/
public static function start($config = null)
{
// don't re-start if we're already running.
if (Solar::$_status) {
return;
}
// make sure these classes are loaded
$list = array('Base', 'Class', 'Config', 'File');
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Solar';
foreach ($list as $name) {
// don't use the autoloader when checking for existence
if (!class_exists('Solar_' . $name, false)) {
require $dir . DIRECTORY_SEPARATOR . "{$name}.php";
}
}
// register autoloader
spl_autoload_register(array('Solar_Class', 'autoload'));
// clear out registered globals
if (ini_get('register_globals')) {
Solar::cleanGlobals();
}
// load config values
Solar_Config::load($config);
// make sure we have the Solar arch-class configs
$arch_config = Solar_Config::get('Solar');
if (!$arch_config) {
Solar_Config::set('Solar', null, Solar::$_Solar);
} else {
Solar_Config::set('Solar', null, array_merge(Solar::$_Solar, (array) $arch_config));
}
// set the system directory
Solar::$system = Solar_Config::get('Solar', 'system');
// process ini settings from config file
$settings = Solar_Config::get('Solar', 'ini_set', array());
foreach ($settings as $key => $val) {
ini_set($key, $val);
}
// user-defined registry entries
$register = Solar_Config::get('Solar', 'registry_set', array());
foreach ($register as $name => $list) {
// make sure we have the class-name and a config
$list = array_pad((array) $list, 2, null);
//.........这里部分代码省略.........
示例10: _setup
/**
*
* 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');
}
示例11: preTest
/**
*
* Setup; runs before each test method.
*
*/
public function preTest()
{
parent::preTest();
Solar_Registry::set('sql', 'Solar_Sql');
}
示例12: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
parent::setup();
Solar_Registry::set('sql', 'Solar_Sql');
Solar_Registry::set('model_catalog', 'Solar_Sql_Model_Catalog');
}
示例13: setup
/**
*
* Setup; runs before each test method.
*
*/
public function setup()
{
parent::setup();
Solar_Registry::set('sql', 'Solar_Sql');
}
示例14: testDependency_registry
public function testDependency_registry()
{
$expect = Solar::factory('Mock_Solar_Example');
Solar_Registry::set('example', $expect);
$actual = Solar::dependency('Mock_Solar_Example', 'example');
$this->assertSame($actual, $expect);
}