【CodeIgniter3】フックを使ってコントローラーを拡張するクラスを複数作成する方法
<?php | |
defined('BASEPATH') OR exit('No direct script access allowed'); | |
class CI_Classes | |
{ | |
private $_include_paths = array(); | |
public function register(array $paths = array()) | |
{ | |
$this->_include_paths = $paths; | |
spl_autoload_register(array($this, "autoloader")); | |
} | |
public function autoloader($class) | |
{ | |
foreach ($this->_include_paths as $path) { | |
$filepath = $path . $class . ".php"; | |
if(!class_exists($class, FALSE) AND is_file($filepath)) { | |
include_once ($filepath); | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment