当前位置: 首页>>代码示例>>PHP>>正文


PHP Configure::instance方法代码示例

本文整理汇总了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";
 }
开发者ID:kurbmedia,项目名称:Valet,代码行数:12,代码来源:Registry.php

示例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;
                     }
                 }
             }
         }
     }
 }
开发者ID:kurbmedia,项目名称:Valet,代码行数:47,代码来源:Authenticator.php

示例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;
     }
 }
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:23,代码来源:Configure.php

示例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();
开发者ID:kurbmedia,项目名称:Valet,代码行数:7,代码来源:config.php


注:本文中的Configure::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。