function addValidator($path, $params = null) { $class = path2class($path); include_once $path; if (isset($this->validators[$class])) { return; } $this->validators[$class] = new $class(); $this->params[$class] = $params; }
protected function onPrepare($argv = null) { $this->thisApp = App::getApp(); $root = $this->getNewAppDir(); if (is_dir($root)) { throw new \Exception("Directory {$root} is existing!"); } $kephpEntry = relative_path($root, $this->thisApp->kephp()); list($path, $phar) = split_phar($kephpEntry); if ($phar !== false) { $kephpEntry = "'phar://' . __DIR__ . '{$path}/{$phar}{$this->entryFile}'"; } else { $kephpEntry = "__DIR__ . '{$path}{$this->entryFile}'"; } $this->context['kephpLibEntry'] = $kephpEntry; if (empty($this->appNamespace)) { $this->appNamespace = path2class($this->name); } else { if (!preg_match('#^[a-z0-9_]+$#i', $this->appNamespace)) { throw new \Exception("App namespace only can use char in a-z0-9_."); } } $this->context['appNamespace'] = trim($this->appNamespace, KE_PATH_NOISE); }
/** * Adds a test-class; we use file extension to determine which class to use. */ function htmlpurifier_add_test($test, $test_file, $only_phpt = false) { switch (strrchr($test_file, ".")) { case '.phpt': return $test->add(new PHPT_Controller_SimpleTest($test_file)); case '.php': require_once $test_file; return $test->add(path2class($test_file)); case '.vtest': return $test->add(new HTMLPurifier_ConfigSchema_ValidatorTestCase($test_file)); case '.htmlt': return $test->add(new HTMLPurifier_HTMLT($test_file)); default: trigger_error("{$test_file} is an invalid file for testing", E_USER_ERROR); } }
public function makeControllerClass(string $controller) { $class = path2class($controller); $class = add_namespace($class, $this->controllerNamespace); return $class; }