本文整理汇总了PHP中registry::set方法的典型用法代码示例。如果您正苦于以下问题:PHP registry::set方法的具体用法?PHP registry::set怎么用?PHP registry::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类registry
的用法示例。
在下文中一共展示了registry::set方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* @param string $id
* @param core_libs $this
*/
function set($id, $lib = null)
{
if ($lib && is_object($lib) && !$lib instanceof Closure) {
$this->_resolved($id, $lib);
}
return parent::set($id, $lib);
}
示例2: __construct
public function __construct($controller, $action)
{
if (isset($_POST['log_out_btn'])) {
$this->logOut();
header('Location: ' . SITE_DIR);
exit;
}
if (isset($_POST['login_btn'])) {
if ($this->auth($_POST['email'], md5($_POST['password']), $_POST['remember'])) {
header('Location: ' . SITE_DIR);
} else {
$this->render('error', true);
}
}
registry::set('log', array());
$this->controller_name = $controller;
$this->check_auth = $this->checkAuth();
if ($this->check_auth) {
// $this->sidebar();
}
$this->action_name = $action . ($this->check_auth ? '_na' : '');
$config = [];
foreach ($this->model('asanatt_system_config')->getAll() as $v) {
$config[$v['config_key']] = $v['config_value'];
}
registry::set('config', $config);
}
示例3: index
public function index()
{
$dates = $this->dates();
$users = [];
foreach ($this->model('asanatt_user_mapping')->getAll() as $user) {
$users[$user['id']] = $user;
}
registry::set('users', $users);
$date_range = [];
for ($i = strtotime($dates['date_from']); $i <= strtotime($dates['date_to']); $i = $i + 3600 * 24) {
$date_range[] = date('Y-m-d', $i);
}
$this->render('date_from', $dates['date_from']);
$this->render('date_to', $dates['date_to']);
$this->render('dates', $date_range);
$this->render('users_list', $this->model('asanatt_user_mapping')->getAll('user_name'));
if (empty($_POST['user'])) {
$this->render('users', $this->model('asanatt_user_mapping')->getAll('user_name'));
} else {
$this->render('users', $this->model('asanatt_user_mapping')->getByField('id', $_POST['user'], true));
}
$this->render('late', $this->model('asanatt_excel_time')->getLateEmployees($dates));
$this->render('absent', $this->model('asanatt_excel_time')->getAbsentEmployees($dates));
$this->render('early', $this->model('asanatt_excel_time')->getEarlyFinished($dates));
$this->render('less_worked', $this->model('asanatt_excel_time')->getLessWorked($dates));
$this->render('overtime', $this->model('asanatt_excel_time')->getOvertime($dates));
$this->view('summary' . DS . 'index');
}
示例4: render
protected function render($key, $value)
{
$common_vars = registry::get('common_vars');
if (!$common_vars) {
$common_vars = [];
}
$common_vars[$key] = $value;
registry::set('common_vars', $common_vars);
}
示例5: getConfig
/**
* @param string $key
* @return string
*/
protected function getConfig($key)
{
if (!$key) {
return false;
}
if (!($value = registry::get('config')[$key])) {
$config = registry::get('config');
$config[$key] = $this->model('system_config')->getByField('config_key', $key)['config_value'];
registry::remove('config');
registry::set('config', $key);
return $config[$key];
} else {
return $value;
}
}
示例6: model
/**
* @param string $model
* @param null/string $table
* @param null/string $db
* @param null/string $user
* @param null/string $password
* @return model
*/
protected function model($model, $table = null, $db = null, $user = null, $password = null)
{
$models = registry::get('models');
if (!($m = $models[$model][$table])) {
$model_file = ROOT_DIR . 'models' . DS . $model . '_model.php';
if (file_exists($model_file)) {
$model_class = $model . '_model';
$m = new $model_class($table ? $table : $model, $db, $user, $password);
} else {
$m = new default_model($model);
}
$models[$model][$table] = $m;
registry::remove('models');
registry::set('models', $models);
}
return $m;
}
示例7: elseif
if (!$_REQUEST['common']) {
if (is_callable($controller->{$ajax_action}())) {
$controller->{$ajax_action}();
}
} else {
if (is_callable($common_controller->index_ajax())) {
$controller->index_ajax();
}
}
} elseif (method_exists($controller, 'catcher_ajax')) {
if (!$_REQUEST['common']) {
if (is_callable($controller->catcher_ajax())) {
$controller->{$ajax_action}();
}
} else {
if (is_callable($common_controller->catcher_ajax())) {
$controller->catcher_ajax();
}
}
}
}
$common_controller->index();
if (method_exists($controller, $action)) {
registry::set('action', $action);
$controller->{$action}();
} elseif (method_exists($controller, 'catcher')) {
$controller->catcher(str_replace('_na', '', $action));
} else {
$controller->default_action();
registry::set('action', 'four_o_four');
}
示例8: log
/**
* @param mixed $value
*/
protected function log($value)
{
$log = registry::get('log');
registry::remove('log');
$log[] = print_r($value, 1);
registry::set('log', $log);
}
示例9: api
protected function api()
{
if (!($api = registry::get('asana_api'))) {
$api = new api_class();
registry::set('asana_api', $api);
}
return $api;
}
示例10: controller_before
function controller_before()
{
$menu = $this->go_deeper();
registry::set('menu', $menu);
}
示例11: __autoload
define("CONFIG_PATH", SITE_PATH . DIRSEP . "config");
define("CORE_PATH", SITE_PATH . DIRSEP . "core");
define("HOST", $_SERVER["HTTP_HOST"]);
define("DEBUG", 1);
# If this is set to 1, searching will far faster but less det
# -ailed. (Using mysql full text natural searching). This for
# if there are many articles.
define("QUICK_SEARCH", 0);
function __autoload($class_name)
{
if (strtolower(substr($class_name, 0, 5)) == "model" && strtolower($class_name) != "model") {
$class_path = SITE_PATH . "models";
$class_name = substr($class_name, 5);
} else {
$class_path = CORE_PATH;
}
$filename = str_replace("_", DIRSEP, strtolower($class_name)) . '.php';
if (file_exists($class_path . DIRSEP . $filename)) {
include $class_path . DIRSEP . $filename;
} else {
die("Could not find " . $class_path . DIRSEP . $filename . "!\n");
return false;
}
}
# System happening
$registry = new registry();
# Load router
$router = new router($registry);
$registry->set('router', $router);
$router->set_path(SITE_PATH . 'controllers');
$router->delegate();
示例12: common_controller
} else {
$controller = 'index';
$action = 'index';
}
$route_parts[0] = $controller;
$route_parts[1] = $action;
registry::set('route_parts', $route_parts);
$class_name = $controller . '_controller';
if (!file_exists(ROOT_DIR . 'controllers' . DS . $class_name . '.php')) {
$class_name = 'default_controller';
}
registry::set('controller', $class_name);
$controller = new $class_name($class_name, $action);
$common_controller = new common_controller($class_name, $action);
$common_controller->index();
if (isset($_REQUEST['ajax']) && $_REQUEST['common']) {
$common_controller->ajax();
}
if (isset($_REQUEST['ajax']) && !$_REQUEST['common']) {
$ajax_action = $action . '_ajax';
if (is_callable($controller->{$ajax_action}())) {
$controller->{$ajax_action}();
}
}
if (method_exists($controller, $action)) {
registry::set('action', $action);
$controller->{$action}();
} else {
$controller->not_found();
registry::set('action', 'not_found');
}