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


PHP Kohana::auto_load方法代码示例

本文整理汇总了PHP中Kohana::auto_load方法的典型用法代码示例。如果您正苦于以下问题:PHP Kohana::auto_load方法的具体用法?PHP Kohana::auto_load怎么用?PHP Kohana::auto_load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kohana的用法示例。


在下文中一共展示了Kohana::auto_load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Sets the payment processing fields.
  * The driver will translate these into the specific format for the provider.
  * Standard fields are (Providers may have additional or different fields):
  *
  * card_num
  * exp_date
  * cvv
  * description
  * amount
  * tax
  * shipping
  * first_name
  * last_name
  * company
  * address
  * city
  * state
  * zip
  * email
  * phone
  * fax
  * ship_to_first_name
  * ship_to_last_name
  * ship_to_company
  * ship_to_address
  * ship_to_city
  * ship_to_state
  * ship_to_zip
  *
  * @param  array  the driver string
  */
 public function __construct($config = array())
 {
     if (empty($config)) {
         // Load the default group
         $config = Kohana::config('payment.default');
     } elseif (is_string($config)) {
         $this->config['driver'] = $config;
     }
     // Merge the default config with the passed config
     is_array($config) and $this->config = array_merge($this->config, $config);
     // Set driver name
     $driver = 'Payment_' . ucfirst($this->config['driver']) . '_Driver';
     // Load the driver
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception('core.driver_not_found', $this->config['driver'], get_class($this));
     }
     // Get the driver specific settings
     $this->config = array_merge($this->config, Kohana::config('payment.' . $this->config['driver']));
     // Initialize the driver
     $this->driver = new $driver($this->config);
     // Validate the driver
     if (!$this->driver instanceof Payment_Driver) {
         throw new Kohana_Exception('core.driver_implements', $this->config['driver'], get_class($this), 'Payment_Driver');
     }
 }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:57,代码来源:Payment.php

示例2: __construct

 /**
  * Loads the configured driver and validates it.
  *
  * @param   array|string  custom configuration or config group name
  * @return  void
  */
 public function __construct($config = FALSE)
 {
     if (is_string($config)) {
         $name = $config;
         // Test the config group name
         if (($config = Kohana::config('cache.' . $config)) === NULL) {
             throw new Cache_Exception('The :group: group is not defined in your configuration.', array(':group:' => $name));
         }
     }
     if (is_array($config)) {
         // Append the default configuration options
         $config += Kohana::config('cache.default');
     } else {
         // Load the default group
         $config = Kohana::config('cache.default');
     }
     // Cache the config in the object
     $this->config = $config;
     // Set driver name
     $driver = 'Cache_' . ucfirst($this->config['driver']) . '_Driver';
     // Load the driver
     if (!Kohana::auto_load($driver)) {
         throw new Cache_Exception('The :driver: driver for the :class: library could not be found', array(':driver:' => $this->config['driver'], ':class:' => get_class($this)));
     }
     // Initialize the driver
     $this->driver = new $driver($this->config['params']);
     // Validate the driver
     if (!$this->driver instanceof Cache_Driver) {
         throw new Cache_Exception('The :driver: driver for the :library: library must implement the :interface: interface', array(':driver:' => $this->config['driver'], ':library:' => get_class($this), ':interface:' => 'Cache_Driver'));
     }
     Kohana_Log::add('debug', 'Cache Library initialized');
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:38,代码来源:Cache.php

示例3: auto_load

 public function auto_load($class)
 {
     if ($this->_run_first) {
         $this->_run_first = FALSE;
         if (is_file($this->_directory . $this->_filename)) {
             // cache expired?
             if (time() - filemtime($this->_directory . $this->_filename) < $this->lifetime) {
                 $this->_cached = TRUE;
                 require $this->_directory . $this->_filename;
                 $this->_classes[$class] = $class;
                 self::$loaded_classes[$class] = $class;
                 if (class_exists($class)) {
                     return TRUE;
                 }
             } else {
                 // Cache has expired
                 unlink($this->_directory . $this->_filename);
             }
         }
     }
     $result = Kohana::auto_load($class);
     $this->_classes[$class] = $class;
     self::$loaded_classes[$class] = $class;
     return $result;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:25,代码来源:cache.php

示例4: __construct

 /**
  * Configuration options.
  *
  * @return  void
  */
 public function __construct()
 {
     $config = array();
     // Append application database configuration
     $config['host'] = Kohana::config('database.default.connection.host');
     $config['user'] = Kohana::config('database.default.connection.user');
     $config['type'] = Kohana::config('database.default.connection.type');
     $config['database'] = Kohana::config('database.default.connection.database');
     $config['table_prefix'] = Kohana::config('database.default.table_prefix');
     // Save the config in the object
     $this->config = $config;
     // Set the driver class name
     $driver = 'DBManager_' . $config['type'] . '_Driver';
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception('core.driver_not_found', $config['type'], get_class($this));
     }
     // Load the driver
     $driver = new $driver($config);
     if (!$driver instanceof DBManager_Driver) {
         throw new Kohana_Exception('core.driver_implements', $config['type'], get_class($this), 'DBManager_Driver');
     }
     // Load the driver for access
     $this->driver = $driver;
     Kohana::log('debug', 'DBManager Library loaded');
     Event::add('system.display', array($this, 'auto_backup'));
     //Event::add('system.display', array($this, 'auto_optimize'));
 }
开发者ID:bogus115,项目名称:kohana-fans-cn,代码行数:32,代码来源:DBManager.php

示例5: add

 /**
  * Add a new message to the log.
  *
  * @param   string  type of message
  * @param   string  message text
  * @return  void
  */
 public static function add($type, $message)
 {
     // Make sure the drivers and config are loaded
     if (!is_array(Kohana_Log::$config)) {
         Kohana_Log::$config = Kohana::config('log');
     }
     if (!is_array(Kohana_Log::$drivers)) {
         foreach ((array) Kohana::config('log.drivers') as $driver_name) {
             // Set driver name
             $driver = 'Log_' . ucfirst($driver_name) . '_Driver';
             // Load the driver
             if (!Kohana::auto_load($driver)) {
                 throw new Kohana_Exception('Log Driver Not Found: %driver%', array('%driver%' => $driver));
             }
             // Initialize the driver
             $driver = new $driver(array_merge(Kohana::config('log'), Kohana::config('log_' . $driver_name)));
             // Validate the driver
             if (!$driver instanceof Log_Driver) {
                 throw new Kohana_Exception('%driver% does not implement the Log_Driver interface', array('%driver%' => $driver));
             }
             Kohana_Log::$drivers[] = $driver;
         }
         // Always save logs on shutdown
         Event::add('system.shutdown', array('Kohana_Log', 'save'));
     }
     Kohana_Log::$messages[] = array('date' => time(), 'type' => $type, 'message' => $message);
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:34,代码来源:Kohana_Log.php

示例6: __construct

 public function __construct($config = array())
 {
     // Append default fURI configuration
     $config += Kohana::config('furi');
     // Check for 'auto' driver and adjust configuration
     if (strtolower($config['driver'] == 'auto')) {
         if (function_exists('curl_init')) {
             $config['driver'] = 'cURL';
         } else {
             $config['driver'] = 'Stream';
         }
     }
     // Save the config in the object
     $this->config = $config;
     // Set the driver class name
     $driver = 'Furi_' . $config['driver'] . '_Driver';
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception('core.driver_not_found', $config['driver'], get_class($this));
     }
     // Load the driver
     $driver = new $driver($config);
     if (!$driver instanceof Furi_Driver) {
         throw new Kohana_Exception('core.driver_implements', $config['driver'], get_class($this), 'Furi_Driver');
     }
     // Load the driver for access
     $this->driver = $driver;
     Kohana::log('debug', 'Furi Library loaded');
 }
开发者ID:nocash,项目名称:fURI,代码行数:28,代码来源:Furi.php

示例7: __construct

    public function __construct($user, $cart)
    {
        $db = new Database();
        $rows = $db->query('
			SELECT d.*, dt.name as discount_name 
			FROM discounts as d 
			LEFT JOIN discounts_types dt ON (d.type_id=dt.id) 
			WHERE (effective_from <= now() OR effective_from="0000:00:00") AND (effective_to >= now() OR effective_to = "0000:00:00")');
        foreach ($rows as $row) {
            $driver = 'Discount_' . $row->discount_name . '_Driver';
            if (!Kohana::auto_load($driver)) {
                throw new Kohana_Exception('core.driver_not_found', $row->discount_name, get_class($this));
            }
            $driver = new $driver($user, $cart);
            $driver->setValues($row);
            if (is_array($amount = $driver->amount())) {
                $this->amount['total'] += $amount['total'];
                if (isset($amount['shippingDiscount'])) {
                    $this->amount['shippingDiscount'] += $amount['shippingDiscount'];
                }
            } else {
                $this->amount['total'] += $amount;
            }
            $this->appliedDiscounts = array_merge($this->appliedDiscounts, $driver->getApplied());
        }
    }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:26,代码来源:Discount.php

示例8: add

 public static function add($controller_name, $method_name, $parameters = array(), $priority = 5, $application_path = '')
 {
     if ($priority < 1 or $priority > 10) {
         Kohana::log('error', 'The priority of the task was out of range!');
         return FALSE;
     }
     $application_path = empty($application_path) ? APPPATH : $application_path;
     $old_module_list = Kohana::config('core.modules');
     Kohana::config_set('core.modules', array_merge($old_module_list, array($application_path)));
     // Make sure the controller name and method are valid
     if (Kohana::auto_load($controller_name)) {
         // Only add it to the queue if the controller method exists
         if (Kohana::config('queue.validate_methods') and !method_exists($controller_name, $method_name)) {
             Kohana::log('error', 'The method ' . $controller_name . '::' . $method_name . ' does not exist.');
             return FALSE;
         }
         // Add the action to the run queue with the priority
         $task = new Task_Model();
         $task->set_fields(array('application' => $application_path, 'class' => $controller_name, 'method' => $method_name, 'params' => serialize($parameters), 'priority' => $priority));
         $task->save();
         // Restore the module list
         Kohana::config_set('core.modules', $old_module_list);
         return TRUE;
     }
     Kohana::log('error', 'The class ' . $controller_name . ' does not exist.');
     return FALSE;
 }
开发者ID:AsteriaGamer,项目名称:steamdriven-kohana,代码行数:27,代码来源:Task_Queue.php

示例9: __call

 /**
  * Handles methods that do not exist.
  *
  * @param   string  method name
  * @param   array   arguments
  * @return  void
  */
 public function __call($method, $args)
 {
     // get(Db/Mem/Tt/Fs)Instance($routeStamp)
     if (substr($method, 0, 3) == 'get' && substr($method, -8) == 'Instance') {
         $baseDriverKey = substr($method, 3, strlen($method) - 11);
         if ($this->configObject->isExistsDriverKey($baseDriverKey) == FALSE) {
             throw new ServRouteInstanceException('Instance.driver_not_supported:' . $baseDriverKey, 500);
         }
         // 路由驱动
         $routeDriver = 'ServRoute_' . $baseDriverKey . '_Driver';
         // 实例驱动
         $instanceDriver = 'ServInstance_' . $baseDriverKey . '_Driver';
         if (!Kohana::auto_load($routeDriver)) {
             throw new ServRouteInstanceException('Instance.route_driver_not_found:' . $baseDriverKey, 500);
         }
         if (!Kohana::auto_load($instanceDriver)) {
             throw new ServRouteInstanceException('Instance.instance_driver_not_found:' . $baseDriverKey, 500);
         }
         // 实例池
         $driverInstancePoolName = $baseDriverKey;
         if (!array_key_exists($driverInstancePoolName, $this->instancePools)) {
             $this->instancePools[$driverInstancePoolName] = array();
         }
         // fast but unflexible
         $thisRouteClassInstance = new $routeDriver($this->configObject->getDriverSetup($baseDriverKey), $args);
         // slow but flexible
         //$rc = new ReflectionClass($routeDriver);$thisRouteClassInstance = $rc->newInstanceArgs($args);
         if (!$thisRouteClassInstance instanceof ServRoute_Driver || !is_subclass_of($thisRouteClassInstance, 'ServRoute_Driver')) {
             throw new ServRouteInstanceException('Instance.route_driver_implements:' . $driverKey, 500);
         }
         // 路由key
         $routeKey = $thisRouteClassInstance->getRouteKey();
         // 初始化Pool中的routeKey
         !isset($this->instancePools[$driverInstancePoolName][$routeKey]) && ($this->instancePools[$driverInstancePoolName][$routeKey] = false);
         if ($this->instancePools[$driverInstancePoolName][$routeKey] !== FALSE && $this->instancePools[$driverInstancePoolName][$routeKey]->isAvailable() == TRUE) {
             // 池中有对应的实例并且可用
             return $this->instancePools[$driverInstancePoolName][$routeKey];
         }
         // 设定池中的实例
         $thisInstanceClassInstance = new $instanceDriver($thisRouteClassInstance);
         if (!$thisInstanceClassInstance instanceof ServInstance_Driver || !is_subclass_of($thisInstanceClassInstance, 'ServInstance_Driver')) {
             throw new ServRouteInstanceException('Instance.instance_driver_implements:' . $driverKey, 500);
         }
         $this->instancePools[$driverInstancePoolName][$routeKey] = $thisInstanceClassInstance;
         if ($this->instancePools[$driverInstancePoolName][$routeKey] !== FALSE) {
             $this->instancePools[$driverInstancePoolName][$routeKey]->isAvailable() or $this->instancePools[$driverInstancePoolName][$routeKey]->setup();
             if ($this->instancePools[$driverInstancePoolName][$routeKey]->isAvailable() != TRUE) {
                 throw new ServRouteInstanceException('Instance.getInstance Failed,Service Not Available.', 500);
             }
             // 池中有对应的实例并且可用
             return $this->instancePools[$driverInstancePoolName][$routeKey];
         }
         throw new ServRouteInstanceException('Instance.getInstance Failed,critical error', 500);
     } else {
         throw new ServRouteInstanceException('Unknown Method', 500);
     }
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:64,代码来源:ServRouteInstance.php

示例10: __construct

 /**
  * Create an instance of Ip.
  *
  * @return  object
  */
 public function __construct()
 {
     $this->config = Kohana::config('ip');
     define('IPDATA_MINI', $this->config['IPDATA_MINI']);
     define('IPDATA_FULL', $this->config['IPDATA_FULL']);
     define('CHARSET', $this->config['CHARSET']);
     $driver = 'Ip_Ip2area_Driver';
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception('core.driver_not_found', $this->config['driver'], get_class($this));
     }
     $this->driver = new $driver();
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:17,代码来源:Ip.php

示例11: action_index

 public function action_index($class)
 {
     // Convert submitted class name to URI segment
     if (isset($_POST['class'])) {
         $this->request->redirect('codebench/' . trim($_POST['class']));
     }
     // Pass the class name on to the view
     $this->template->class = (string) $class;
     // Try to load the class, then run it
     if (Kohana::auto_load($class) === TRUE) {
         $codebench = new $class();
         $this->template->codebench = $codebench->run();
     }
 }
开发者ID:laiello,项目名称:ko3,代码行数:14,代码来源:codebench.php

示例12: __construct

 public function __construct($name)
 {
     // Set driver name
     $driver = 'Mymonitor_' . ucfirst($name) . '_Driver';
     // Load the driver
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception($driver . '.driver_not_found', $name, get_class($this));
     }
     // Initialize the driver
     $this->driver = new $driver($name);
     // Validate the driver
     if (!$this->driver instanceof Mymonitor_Driver) {
         throw new Kohana_Exception('core.driver_implements', $name, get_class($this), 'Mymonitor_Driver');
     }
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:15,代码来源:Mymonitor.php

示例13: action_index

 public function action_index()
 {
     $class = $this->request->param('class');
     // Convert submitted class name to URI segment
     if (isset($_POST['class'])) {
         throw HTTP_Exception::factory(302)->location('codebench/' . trim($_POST['class']));
     }
     // Pass the class name on to the view
     $this->template->class = (string) $class;
     // Try to load the class, then run it
     if (Kohana::auto_load($class) === TRUE) {
         $codebench = new $class();
         $this->template->codebench = $codebench->run();
     }
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:15,代码来源:Codebench.php

示例14: __construct

 public function __construct($company, $zip, $country_code, $basket)
 {
     if (empty($company)) {
         throw new Kohana_Exception('core.shipping_company_not_provided', $d, get_class($this));
     }
     $driver = 'Shipping_' . ucfirst($company) . '_Driver';
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception('core.driver_not_found', $company, get_class($this));
     }
     $this->driver = new $driver();
     $this->shipping = $this->get();
     $this->basket = $basket;
     $this->destination->zip = $zip;
     $this->destination->country = $country_code;
 }
开发者ID:VinceOmega,项目名称:mcb-nov-build,代码行数:15,代码来源:Shipping.php

示例15: __construct

 public function __construct($api)
 {
     //driver启动
     $driver = 'Mydomaininterface_' . ucfirst($api) . '_Driver';
     // Load the driver
     if (!Kohana::auto_load($driver)) {
         throw new Kohana_Exception($driver . '.driver_not_found', $api, get_class($this));
     }
     // Initialize the driver
     $this->driver = new $driver();
     // Validate the driver
     if (!$this->driver instanceof Mydomaininterface_Driver) {
         throw new Kohana_Exception('core.driver_implements', $api, get_class($this), 'Mydomain_interface_Driver');
     }
 }
开发者ID:RenzcPHP,项目名称:3dproduct,代码行数:15,代码来源:Mydomaininterface.php


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