本文整理汇总了PHP中Configure::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::instance方法的具体用法?PHP Configure::instance怎么用?PHP Configure::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Configure
的用法示例。
在下文中一共展示了Configure::instance方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @return void
**/
public function __construct()
{
$config = \Configure::instance();
$this->plugins = $config->plugins;
$this->_view_vars = array();
$this->layout = isset($config->options['layout']) && !empty($config->options['layout']) ? $config->options['layout'] : "main";
}
示例2: validate
public static function validate($request)
{
$config = \Configure::instance();
$data = $config->authentication;
if (empty($data)) {
return null;
}
foreach ($data as $url => $values) {
$redirect = isset($values['on_fail']) ? $values['on_fail'] : "/";
if (preg_match('@' . $url . '/?@i', $request)) {
// Match the requested url.
if (!isset($values['allow'])) {
throw new Exception('Invalid user type or user type not set for protected url ' . $request);
}
$valid_user = $values['allow'];
if (is_array($valid_user)) {
// Access list is an array of user types.
$pass = false;
foreach ($valid_user as $user) {
if (self::get() == $user) {
$pass = true;
}
}
// Check list of users for match
if ($pass == false) {
if (!preg_match('@' . $request . '/?@i', $redirect)) {
\Controller\Flash::instance()->error('You must be logged in to access this page.');
Application::redirect($redirect);
break;
}
}
} else {
// Access list is a single user type.
$valid_user = strtolower($valid_user);
if (self::get() != $valid_user) {
// If user isn't allowed, redirect.
if (!preg_match('@' . $request . '/?@i', $redirect)) {
\Controller\Flash::instance()->error('You must be logged in to access this page.');
header('HTTP/1.0 401 Unauthorized');
header("Location:" . $redirect);
exit;
}
}
}
}
}
}
示例3: find
public static function find($namespace = null)
{
$namespace = strtolower($namespace);
if (!self::$instance) {
self::$instance = new self();
}
if ($namespace) {
if (!self::$instance->exists($namespace)) {
self::$instance->write($namespace, null);
}
$configure = clone self::$instance;
$configure->namespace = $namespace;
$configure->data =& self::$instance->data;
$namespace_parts = explode('.', $namespace);
$len = sizeof($namespace_parts);
for ($i = 0; $i < $len; $i++) {
$configure->data =& $configure->data[$namespace_parts[$i]];
}
return $configure;
} else {
return self::$instance;
}
}
示例4: array
<?php
$config = Configure::instance();
$config->project = array('name' => 'Valet', 'description' => 'Valet framework sample site.');
$config->options = array('layout' => 'main', 'caching' => false);
$config->authentication = array('admin/?(.*)?' => array('allow' => 'admin', 'on_fail' => '/'));
$config->plugins = array();