/** * Creates a new RequestHandler object. * * @param string $className * @param array $applicationDir * @param string $type */ protected function __construct($className, $applicationDir, $type) { self::$activeRequest = $this; try { // validate class name if (!preg_match('/^[a-z0-9_]+$/i', $className)) { throw new SystemException("Illegal class name '" . $className . "'", 11009); } // find class $className = ucfirst($className) . ucfirst($type); $classPath = $type . '/' . $className . '.class.php'; $found = false; foreach ($applicationDir as $dir) { if (file_exists($dir . $classPath)) { $classPath = $dir . $classPath; $found = true; break; } } if (!$found) { throw new SystemException("unable to find class file '" . $classPath . "'", 11000); } } catch (SystemException $e) { throw new IllegalLinkException(); } // define vars $this->type = $type; $this->{$type} = $className; // include class require_once $classPath; // execute class if (!class_exists($className)) { throw new SystemException("unable to find class '" . $className . "'", 11001); } $this->controllerObj = new $className(); }