本文整理汇总了PHP中Registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::set方法的具体用法?PHP Registry::set怎么用?PHP Registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: database
public function database($driver, $hostname, $username, $password, $database, $prefix = null, $charset = 'UTF8')
{
$file = DIR_ROOT . "'/system/database/{$driver}.php";
$class = 'Database' . preg_replace('/[^a-zA-Z0-9]/', '', $driver);
if (file_exists($file)) {
include $file;
$this->registry->set(str_replace('/', '_', $driver), new $class());
} else {
trigger_error('Error: Could not load database ' . $driver . '!');
exit;
}
}
示例2: loadCms
/**
* Load all specific cms data.
*/
public function loadCms()
{
$this->fileConfig->loadConfigFromFile(CONFIG_PATH . '/config.php');
if ($this->fileConfig->get('dbUser') !== null) {
/*
* Cms is installed
*/
if ($this->fileConfig->get('debugModus') === false) {
@ini_set('display_errors', 'off');
error_reporting(0);
}
$dbFactory = new Database\Factory();
$db = $dbFactory->getInstanceByConfig($this->fileConfig);
$databaseConfig = new Config\Database($db);
$databaseConfig->loadConfigFromDatabase();
Registry::set('db', $db);
Registry::set('config', $databaseConfig);
$this->plugin->addPluginData('db', $db);
$this->plugin->addPluginData('config', $databaseConfig);
$this->plugin->addPluginData('translator', $this->translator);
$this->plugin->execute('AfterDatabaseLoad');
$this->router->defineStartPage($databaseConfig->get('start_page'), $this->translator);
} else {
/*
* Cms not installed yet.
*/
$this->request->setModuleName('install');
if (!empty($_SESSION['language'])) {
$this->translator->setLocale($_SESSION['language']);
}
}
}
示例3: get
/**
* Получение настроек
* @param string $key Имя настройки
* @return string Значение настройки
*/
public static function get($key)
{
if (!Registry::has('setting')) {
Registry::set('setting', App::arrayAssoc(self::all(), 'name', 'value'));
}
return Registry::get('setting')[$key];
}
示例4: getController2
public function getController2()
{
$route = pathinfo(Request::getVar("route9sd3jdk3", "GET") . "/1.1");
unset($_GET["route9sd3jdk3"]);
$route = $route["dirname"];
$route = preg_replace("/index\\.php\$/i", "", $route);
$route = preg_replace("/\\/\$/", "", $route);
if (($rm = RoadMap::get()) != NULL) {
$found = false;
$i = 0;
$matches = array();
for (; !$found && $i < count($rm); $i++) {
$found = preg_match_all("/^" . addcslashes($rm[$i]["url"], "/") . "\$/", $route, $matches);
}
if ($found && $rm[$i - 1]["hasPage"] != 0) {
$name = ucfirst($rm[$i - 1]["ctrl"]);
$ctrl = Class_routines::loadClass(__ROOT_PATH . DS . "controller" . DS . "ctrl" . $name . ".class.php");
Registry::set("controllerParams", array("route" => $route, "XHROnly" => $rm[$i - 1]["XHROnly"]));
Registry::set("viewName", $name);
Registry::set("controller", new $ctrl());
Registry::set("route:params", $matches);
return Registry::get("controller");
} else {
self::raiseException(!$found ? ERR_ROUTER_NO_ROUTE_FOUND : ERR_ROUTE_IS_NOT_LEAF, $route);
return NULL;
}
}
}
示例5: beforeroute
public function beforeroute()
{
$this->response = new \View\Backend();
\Registry::set('VIEW', $this->response);
$this->response->addTitle(\Base::instance()->get('LN__AdminCP'));
$this->hasSub = $this->showMenu($this->moduleBase);
}
示例6: render
static function render()
{
$args = func_get_args();
$action = $args[0];
$controller = isset($args[1]) ? $args[1] : self::controller_name();
$controllerClass = $controller . 'Controller';
$ContrArgs = isset($args[2]) ? $args[2] : '';
if (!is_callable(array($controllerClass, $action))) {
if (is_file('controllers/' . $controller . '_controller.php')) {
include 'controllers/' . $controller . '_controller.php';
}
Registry::set('controller', $controller, true);
//loading model
if (is_file('models/' . $controller . '.php')) {
include 'models/' . $controller . '.php';
} else {
Registry::addDebug('<div class="notice">Notice: No model For: <i>"' . $controller . '"</i> controller</div>');
}
$controllerClass::$action($ContrArgs);
ob_start();
include 'views/' . $controller . '/' . $action . '.html.php';
Registry::set('content', ob_get_contents());
ob_end_clean();
}
}
示例7: __construct
public function __construct()
{
$this->prefix = DB_PREFIX;
$this->sdsdb = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry = new Registry();
$registry->set('db', $this->sdsdb);
}
示例8: start
public static function start()
{
$config = Registry::get('config');
if (isset($config->session)) {
// optional parameters sent to the constructor
if (isset($config->session->params)) {
$sessionParams = $config->session->params;
}
if (is_object($config->session->handler)) {
$sessionHandler = self::factory($config->session->handler->namespace, $config->session->handler->class, $sessionParams, $config->session->lifetime);
} else {
$sessionHandler = self::factory('Nf\\Session', $config->session->handler, $sessionParams, $config->session->lifetime);
}
session_name($config->session->cookie->name);
session_set_cookie_params(0, $config->session->cookie->path, $config->session->cookie->domain, false, true);
session_set_save_handler(array(&$sessionHandler, 'open'), array(&$sessionHandler, 'close'), array(&$sessionHandler, 'read'), array(&$sessionHandler, 'write'), array(&$sessionHandler, 'destroy'), array(&$sessionHandler, 'gc'));
register_shutdown_function('session_write_close');
session_start();
// session_regenerate_id(true);
Registry::set('session', $sessionHandler);
return $sessionHandler;
} else {
return false;
}
}
示例9: register
/**
* Register a plugin with the registry in the given category.
* @param $category String the name of the category to extend
* @param $plugin The instantiated plugin to add
* @param $path The path the plugin was found in
* @return boolean True IFF the plugin was registered successfully
*/
function register($category, &$plugin, $path)
{
// Normalize plugin name to lower case for
// PHP4 compatibility in case we use class names here.
$pluginName = $plugin->getName();
$plugins =& PluginRegistry::getPlugins();
if (!$plugins) {
$plugins = array();
}
// If the plugin was already loaded, do not load it again.
if (isset($plugins[$category][$pluginName])) {
return false;
}
// Allow the plugin to register.
if (!$plugin->register($category, $path)) {
return false;
}
if (isset($plugins[$category])) {
$plugins[$category][$pluginName] =& $plugin;
} else {
$plugins[$category] = array($pluginName => &$plugin);
}
Registry::set('plugins', $plugins);
return true;
}
示例10: post_list
function post_list()
{
// only run on the first call
if (!Registry::has('rwar_post_archive')) {
// capture original article if one is set
if ($article = Registry::get('article')) {
Registry::set('original_article', $article);
}
}
if (!($posts = Registry::get('rwar_post_archive'))) {
$posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
Registry::set('rwar_post_archive', $posts = new Items($posts));
}
if ($result = $posts->valid()) {
// register single post
Registry::set('article', $posts->current());
// move to next
$posts->next();
} else {
// back to the start
$posts->rewind();
// reset original article
Registry::set('article', Registry::get('original_article'));
// remove items
Registry::set('rwar_post_archive', false);
}
return $result;
}
示例11: rub_create
public static function rub_create()
{
$currencies = Registry::get('currencies');
$symbol = SYMBOL_RUBL;
if (empty($currencies[CURRENCY_RUB])) {
$rub = array('currency_code' => CURRENCY_RUB, 'after' => 'Y', 'symbol' => $symbol, 'coefficient' => '1', 'is_primary' => 'Y', 'position' => '0', 'decimals_separator' => '', 'thousands_separator' => '', 'decimals' => '0', 'status' => 'A');
db_query("UPDATE ?:currencies SET is_primary = 'N' WHERE is_primary = 'Y'");
$rub_id = db_query('INSERT INTO ?:currencies ?e', $rub);
if (!empty($rub_id)) {
$rub_array = $rub;
$rub_array['currency_id'] = $rub_id;
Registry::set('currencies.RUB', $rub_array);
foreach (fn_get_translation_languages() as $lang_code => $v) {
db_query("REPLACE INTO ?:currency_descriptions (`currency_code`, `description`, `lang_code`) VALUES (?s, 'Рубли', ?s)", CURRENCY_RUB, $lang_code);
}
fn_set_notification('N', __('notice'), __('rus_ruble.symbol_rub_created'));
}
} else {
if ($currencies[CURRENCY_RUB]['is_primary'] == 'N') {
db_query("UPDATE ?:currencies SET is_primary = 'N' WHERE is_primary = 'Y'");
db_query("UPDATE ?:currencies SET is_primary = 'Y', coefficient = 1 WHERE currency_code = ?s", CURRENCY_RUB);
}
if ($currencies[CURRENCY_RUB]['symbol'] != $symbol) {
self::symbol_update($symbol);
}
}
return true;
}
示例12: register
/**
* Register a plugin with the registry in the given category.
* @param $category String the name of the category to extend
* @param $plugin The instantiated plugin to add
* @param $path The path the plugin was found in
* @return boolean True IFF the plugin was registered successfully
*/
function register($category, &$plugin, $path)
{
$pluginName = $plugin->getName();
$plugins =& PluginRegistry::getPlugins();
if (!$plugins) {
$plugins = array();
}
// If the plugin was already loaded, do not load it again.
if (isset($plugins[$category][$pluginName])) {
return false;
}
// Initialize the plug-in
// FIXME: Move this to the hook registry once caching is implemented
if (!$plugin->initialize($category, $path)) {
return false;
}
// Allow the plugin to register.
if (!$plugin->register($category, $path)) {
return false;
}
if (isset($plugins[$category])) {
$plugins[$category][$plugin->getName()] =& $plugin;
} else {
$plugins[$category] = array($plugin->getName() => &$plugin);
}
Registry::set('plugins', $plugins);
return true;
}
示例13: addEntry
public static function addEntry($type, $action, $uid = FALSE)
{
if (\Registry::exists('LOGGER')) {
$logger = \Registry::get('LOGGER');
} else {
$logger = new self();
\Registry::set('LOGGER', $logger);
}
/*
eFiction 3 log types:
"RG" => _NEWREG
"ED" => _ADMINEDIT
"DL" => _ADMINDELETE
"VS" => _VALIDATESTORY
"LP"=> _LOSTPASSWORD
"BL" => _BADLOGIN
"RE" => "Reviews"
"AM" => "Admin Maintenance"
"EB" => _EDITBIO
*/
// Force add entry
$logger->reset();
// Submitted data:
$logger->type = $type;
$logger->action = $action;
// Use id of active user, unless specified
$logger->uid = $uid ? $uid : $_SESSION['userID'];
$logger->ip = $_SERVER['REMOTE_ADDR'];
$logger->version = 2;
// Add entry
$test = $logger->save();
}
示例14: register
function register($category, $path)
{
if (parent::register($category, $path)) {
error_log('OJS - UHBP: der Haken wird registriert.');
Registry::set('UserHomeBlockPlugin', $this);
HookRegistry::register('Templates::User::Index::MyAccount', array(&$this, 'callback'));
}
}
示例15: Registry
/**
* Set or retrieve an object
*
* @param $key string entry key to set or get
* @param $instance optional object. If provided, set the entry
* for $key to this object. If not provided, return the entry
* for $key. If null, clear the entry for $key.
*
* @return object|null
*/
function Registry($key, $instance = -1)
{
if ($instance === -1) {
return Registry::get($key);
} else {
return Registry::set($key, $instance);
}
}