當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。