Created
September 14, 2010 09:25
-
-
Save okonomi/578786 to your computer and use it in GitHub Desktop.
URLによってコントローラを切り替える for Ethna
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 | |
/* | |
URLによってコントローラを切り替える | |
*/ | |
require_once 'Net/URL/Mapper.php'; | |
$router = Net_URL_Mapper::getInstance(); | |
$router->connect('/:controller*params', array('controller' => 'default'), array('controller' => '[a-zA-Z_]+')); | |
$result = $router->match(@$_SERVER['PATH_INFO']); | |
$controller_class = sprintf('Sample_%sController', ucfirst($result['controller'])); | |
$controller_file = sprintf('%s/%s.php', dirname(__FILE__) . '/../app/controller', $controller_class); | |
require_once $controller_file; | |
call_user_func_array(array($controller_class, 'main'), array($controller_class, 'index')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment