public function testSubPathTemplateLoading() { $output = TemplateEngine::render('some_login.tpl.php', array()); $this->assertEquals("This is a Login Page?", $output); TemplateEngine::prependPath("tests/files/views/secondary"); $output = TemplateEngine::render('some_login.tpl.php', array()); $this->assertEquals("Is this another Login Page?", $output); TemplateEngine::reset(); TemplateEngine::appendPath('tests/files/views'); }
public static function run() { Session::start(); honam\TemplateEngine::prependPath('views/shared'); honam\TemplateEngine::prependPath('views/layouts'); honam\AssetsLoader::setSiteUrl(Url::path('public')); honam\AssetsLoader::appendSourceDir('assets'); honam\AssetsLoader::setDestinationDir('public'); honam\Helper::setBaseUrl(Url::path('')); self::getRouter()->execute(substr(utils\Input::server('REQUEST_URI'), 1)); }
public function executeControllerAction($action, $params) { $name = $this->getName(); $path = Text::camelize($action); $return = null; $invokeParameters = []; if ($methodDetails = $this->getMethod($path)) { panie\InjectionContainer::bind(controllers\ModelBinderInterface::class)->to($methodDetails['binder']); $method = new \ReflectionMethod($this, $methodDetails['name']); honam\TemplateEngine::prependPath("views/{$name}"); if (View::getTemplate() == null) { View::setTemplate("{$name}_{$action}" . '.tpl.php'); } $methodParameters = $method->getParameters(); foreach ($methodParameters as $methodParameter) { $this->bindParameter($invokeParameters, $methodParameter, $params); } $method->invokeArgs($this, $invokeParameters); $return = View::out(); echo $return; return; } else { foreach ($this->loadedComponents as $component) { //@todo Look at how to prevent this from running several times if ($component->hasMethod($path)) { $component->executeControllerAction($path, $params); return; } } } throw new exceptions\ControllerActionNotFoundException($this, $path); }