Last active
April 1, 2016 08:52
-
-
Save kurozumi/32fec6a87ad9c3d799cd to your computer and use it in GitHub Desktop.
【CodeIgniter3】フックを使ってコントローラーを拡張するクラスを複数作成する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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