Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 1 | <?php |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 2 | /** |
| 3 | * CodeIgniter |
| 4 | * |
Phil Sturgeon | 07c1ac8 | 2012-03-09 17:03:37 +0000 | [diff] [blame] | 5 | * An open source application development framework for PHP 5.2.4 or newer |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 6 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 7 | * NOTICE OF LICENSE |
Andrey Andreev | 83d1505 | 2011-12-22 13:35:42 +0200 | [diff] [blame] | 8 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 9 | * Licensed under the Open Software License version 3.0 |
Andrey Andreev | 83d1505 | 2011-12-22 13:35:42 +0200 | [diff] [blame] | 10 | * |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 11 | * This source file is subject to the Open Software License (OSL 3.0) that is |
| 12 | * bundled with this package in the files license.txt / license.rst. It is |
| 13 | * also available through the world wide web at this URL: |
| 14 | * http://opensource.org/licenses/OSL-3.0 |
| 15 | * If you did not receive a copy of the license and are unable to obtain it |
| 16 | * through the world wide web, please send an email to |
| 17 | * licensing@ellislab.com so we can send you a copy immediately. |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 18 | * |
| 19 | * @package CodeIgniter |
| 20 | * @author EllisLab Dev Team |
Andrey Andreev | 80500af | 2013-01-01 08:16:53 +0200 | [diff] [blame] | 21 | * @copyright Copyright (c) 2006 - 2013, EllisLab, Inc. (http://ellislab.com/) |
Derek Jones | f4a4bd8 | 2011-10-20 12:18:42 -0500 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 23 | * @link http://codeigniter.com |
| 24 | * @since Version 1.0 |
| 25 | * @filesource |
| 26 | */ |
Andrey Andreev | c5536aa | 2012-11-01 17:33:58 +0200 | [diff] [blame] | 27 | defined('BASEPATH') OR exit('No direct script access allowed'); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 28 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 29 | /** |
| 30 | * CodeIgniter Driver Library Class |
| 31 | * |
| 32 | * This class enables you to create "Driver" libraries that add runtime ability |
| 33 | * to extend the capabilities of a class via additional driver objects |
| 34 | * |
| 35 | * @package CodeIgniter |
| 36 | * @subpackage Libraries |
| 37 | * @category Libraries |
| 38 | * @author EllisLab Dev Team |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 39 | * @link |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 40 | */ |
| 41 | class CI_Driver_Library { |
| 42 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 43 | /** |
| 44 | * Array of drivers that are available to use with the driver class |
| 45 | * |
| 46 | * @var array |
| 47 | */ |
| 48 | protected $valid_drivers = array(); |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 49 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 50 | /** |
| 51 | * Name of the current class - usually the driver class |
| 52 | * |
| 53 | * @var string |
| 54 | */ |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 55 | protected $lib_name; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 56 | |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 57 | /** |
| 58 | * Get magic method |
| 59 | * |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 60 | * The first time a child is used it won't exist, so we instantiate it |
| 61 | * subsequents calls will go straight to the proper child. |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 62 | * |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 63 | * @param string Child class name |
| 64 | * @return object Child class |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 65 | */ |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 66 | public function __get($child) |
Andrey Andreev | 2e3e230 | 2012-10-09 15:52:34 +0300 | [diff] [blame] | 67 | { |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 68 | // Try to load the driver |
dchill42 | c587225 | 2012-07-30 14:53:11 -0400 | [diff] [blame] | 69 | return $this->load_driver($child); |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 70 | } |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 71 | |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 72 | /** |
| 73 | * Load driver |
| 74 | * |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 75 | * Separate load_driver call to support explicit driver load by library or user |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 76 | * |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 77 | * @param string Driver name (w/o parent prefix) |
| 78 | * @return object Child class |
Darren Hill | 6fbf6bd | 2011-08-31 14:15:35 -0400 | [diff] [blame] | 79 | */ |
Darren Hill | c4e266b | 2011-08-30 15:40:27 -0400 | [diff] [blame] | 80 | public function load_driver($child) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 81 | { |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 82 | // Get CodeIgniter instance and subclass prefix |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 83 | $prefix = config_item('subclass_prefix'); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 84 | |
Pascal Kriete | 14287f3 | 2011-02-14 13:39:34 -0500 | [diff] [blame] | 85 | if ( ! isset($this->lib_name)) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 86 | { |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 87 | // Get library name without any prefix |
| 88 | $this->lib_name = str_replace(array('CI_', $prefix), '', get_class($this)); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 89 | } |
| 90 | |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 91 | // The child will be prefixed with the parent lib |
| 92 | $child_name = $this->lib_name.'_'.$child; |
Andrey Andreev | 83d1505 | 2011-12-22 13:35:42 +0200 | [diff] [blame] | 93 | |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 94 | // See if requested child is a valid driver |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 95 | if ( ! in_array($child, $this->valid_drivers)) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 96 | { |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 97 | // The requested driver isn't valid! |
| 98 | $msg = 'Invalid driver requested: '.$child_name; |
| 99 | log_message('error', $msg); |
| 100 | show_error($msg); |
| 101 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 102 | |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 103 | // Get package paths and filename case variations to search |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 104 | $CI = get_instance(); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 105 | $paths = $CI->load->get_package_paths(TRUE); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 106 | |
| 107 | // Is there an extension? |
| 108 | $class_name = $prefix.$child_name; |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 109 | $found = class_exists($class_name, FALSE); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 110 | if ( ! $found) |
| 111 | { |
| 112 | // Check for subclass file |
| 113 | foreach ($paths as $path) |
| 114 | { |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 115 | // Does the file exist? |
| 116 | $file = $path.'libraries/'.$this->lib_name.'/drivers/'.$prefix.$child_name.'.php'; |
| 117 | if (file_exists($file)) |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 118 | { |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 119 | // Yes - require base class from BASEPATH |
| 120 | $basepath = BASEPATH.'libraries/'.$this->lib_name.'/drivers/'.$child_name.'.php'; |
| 121 | if ( ! file_exists($basepath)) |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 122 | { |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 123 | $msg = 'Unable to load the requested class: CI_'.$child_name; |
| 124 | log_message('error', $msg); |
| 125 | show_error($msg); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 126 | } |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 127 | |
| 128 | // Include both sources and mark found |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 129 | include_once($basepath); |
| 130 | include_once($file); |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 131 | $found = TRUE; |
| 132 | break; |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | // Do we need to search for the class? |
| 138 | if ( ! $found) |
| 139 | { |
| 140 | // Use standard class name |
| 141 | $class_name = 'CI_'.$child_name; |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 142 | if ( ! class_exists($class_name, FALSE)) |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 143 | { |
| 144 | // Check package paths |
| 145 | foreach ($paths as $path) |
| 146 | { |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 147 | // Does the file exist? |
| 148 | $file = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_name.'.php'; |
| 149 | if (file_exists($file)) |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 150 | { |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 151 | // Include source |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 152 | include_once($file); |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 153 | break; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 154 | } |
| 155 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 156 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 157 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 158 | |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 159 | // Did we finally find the class? |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 160 | if ( ! class_exists($class_name, FALSE)) |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 161 | { |
Andrey Andreev | 662e342 | 2013-01-28 21:19:13 +0200 | [diff] [blame^] | 162 | if (class_exists($child_name, FALSE)) |
William Knauss | 401fb49 | 2012-11-27 00:01:03 -0500 | [diff] [blame] | 163 | { |
| 164 | $class_name = $child_name; |
| 165 | } |
| 166 | else |
| 167 | { |
| 168 | $msg = 'Unable to load the requested driver: '.$class_name; |
| 169 | log_message('error', $msg); |
| 170 | show_error($msg); |
| 171 | } |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 172 | } |
| 173 | |
Andrey Andreev | 7e83f32 | 2012-11-25 16:03:21 +0200 | [diff] [blame] | 174 | // Instantiate, decorate and add child |
| 175 | $obj = new $class_name(); |
dchill42 | 6262d05 | 2012-11-24 18:41:13 -0500 | [diff] [blame] | 176 | $obj->decorate($this); |
| 177 | $this->$child = $obj; |
| 178 | return $this->$child; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 179 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 180 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 181 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 182 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 183 | // -------------------------------------------------------------------------- |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * CodeIgniter Driver Class |
| 187 | * |
| 188 | * This class enables you to create drivers for a Library based on the Driver Library. |
| 189 | * It handles the drivers' access to the parent library |
| 190 | * |
| 191 | * @package CodeIgniter |
| 192 | * @subpackage Libraries |
| 193 | * @category Libraries |
| 194 | * @author EllisLab Dev Team |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 195 | * @link |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 196 | */ |
| 197 | class CI_Driver { |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 198 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 199 | /** |
| 200 | * Instance of the parent class |
| 201 | * |
| 202 | * @var object |
| 203 | */ |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 204 | protected $_parent; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 205 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 206 | /** |
| 207 | * List of methods in the parent class |
| 208 | * |
| 209 | * @var array |
| 210 | */ |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 211 | protected $_methods = array(); |
Andrey Andreev | 5645479 | 2012-05-17 14:32:19 +0300 | [diff] [blame] | 212 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 213 | /** |
| 214 | * List of properties in the parent class |
| 215 | * |
| 216 | * @var array |
| 217 | */ |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 218 | protected $_properties = array(); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 219 | |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 220 | /** |
| 221 | * Array of methods and properties for the parent class(es) |
| 222 | * |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 223 | * @static |
| 224 | * @var array |
Timothy Warren | 0688ac9 | 2012-04-20 10:25:04 -0400 | [diff] [blame] | 225 | */ |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 226 | protected static $_reflections = array(); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 227 | |
| 228 | /** |
| 229 | * Decorate |
| 230 | * |
| 231 | * Decorates the child with the parent driver lib's methods and properties |
| 232 | * |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 233 | * @param object |
| 234 | * @return void |
| 235 | */ |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 236 | public function decorate($parent) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 237 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 238 | $this->_parent = $parent; |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 239 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 240 | // Lock down attributes to what is defined in the class |
| 241 | // and speed up references in magic methods |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 242 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 243 | $class_name = get_class($parent); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 244 | |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 245 | if ( ! isset(self::$_reflections[$class_name])) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 246 | { |
| 247 | $r = new ReflectionObject($parent); |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 248 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 249 | foreach ($r->getMethods() as $method) |
| 250 | { |
| 251 | if ($method->isPublic()) |
| 252 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 253 | $this->_methods[] = $method->getName(); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | |
Pascal Kriete | 14287f3 | 2011-02-14 13:39:34 -0500 | [diff] [blame] | 257 | foreach ($r->getProperties() as $prop) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 258 | { |
| 259 | if ($prop->isPublic()) |
| 260 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 261 | $this->_properties[] = $prop->getName(); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 262 | } |
| 263 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 264 | |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 265 | self::$_reflections[$class_name] = array($this->_methods, $this->_properties); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 266 | } |
| 267 | else |
| 268 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 269 | list($this->_methods, $this->_properties) = self::$_reflections[$class_name]; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 270 | } |
| 271 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 272 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 273 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 274 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 275 | /** |
| 276 | * __call magic method |
| 277 | * |
| 278 | * Handles access to the parent driver library's methods |
| 279 | * |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 280 | * @param string |
| 281 | * @param array |
| 282 | * @return mixed |
| 283 | */ |
| 284 | public function __call($method, $args = array()) |
| 285 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 286 | if (in_array($method, $this->_methods)) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 287 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 288 | return call_user_func_array(array($this->_parent, $method), $args); |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | $trace = debug_backtrace(); |
| 292 | _exception_handler(E_ERROR, "No such method '{$method}'", $trace[1]['file'], $trace[1]['line']); |
| 293 | exit; |
| 294 | } |
| 295 | |
| 296 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 297 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 298 | /** |
| 299 | * __get magic method |
| 300 | * |
| 301 | * Handles reading of the parent driver library's properties |
| 302 | * |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 303 | * @param string |
| 304 | * @return mixed |
| 305 | */ |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 306 | public function __get($var) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 307 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 308 | if (in_array($var, $this->_properties)) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 309 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 310 | return $this->_parent->$var; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 311 | } |
| 312 | } |
| 313 | |
| 314 | // -------------------------------------------------------------------- |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 315 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 316 | /** |
| 317 | * __set magic method |
| 318 | * |
| 319 | * Handles writing to the parent driver library's properties |
| 320 | * |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 321 | * @param string |
| 322 | * @param array |
| 323 | * @return mixed |
| 324 | */ |
Greg Aker | a926328 | 2010-11-10 15:26:43 -0600 | [diff] [blame] | 325 | public function __set($var, $val) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 326 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 327 | if (in_array($var, $this->_properties)) |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 328 | { |
Andrey Andreev | 8486e9c | 2012-03-26 20:24:12 +0300 | [diff] [blame] | 329 | $this->_parent->$var = $val; |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 330 | } |
| 331 | } |
Barry Mieny | dd67197 | 2010-10-04 16:33:58 +0200 | [diff] [blame] | 332 | |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 333 | } |
Derek Jones | 8dca041 | 2010-03-05 13:01:44 -0600 | [diff] [blame] | 334 | |
| 335 | /* End of file Driver.php */ |
Andrey Andreev | 2e3e230 | 2012-10-09 15:52:34 +0300 | [diff] [blame] | 336 | /* Location: ./system/libraries/Driver.php */ |