public function testGetControllerNameShouldWork() { $router = $this->getRouter(); $router->enableSearchEngineFriendly(false); $app = new Piano\Application($this->getConfig(), $router); $app->setUrl('/admin/index/index'); $this->assertEquals('IndexController', $app->getControllerName()); $app->setUrl('/upload/image/index'); $this->assertEquals('ImageController', $app->getControllerName()); }
public function render($viewName = null, array $vars = null) { if (is_null($viewName)) { throw new InvalidArgumentException('View name is expected.'); } $controller = strtolower(preg_replace('/Controller$/', '', $this->application->getControllerName())); $viewPath = '/modules/' . $this->application->getModuleName() . '/views/' . $controller . '/' . $viewName; $layoutPath = '/layouts/' . $this->getPathLayout(); if (!file_exists($this->getCompleteViewPath($layoutPath))) { die('Layout ' . $this->getPathLayout() . '.phtml does not exist.'); // @codeCoverageIgnore } if (is_array($vars) && count($vars) > 0) { $vars['view'] = $this->getCompleteViewPath($viewPath); } else { $vars = ['view' => $this->getCompleteViewPath($viewPath)]; } if ($this->disableLayout) { $this->partial($viewPath, $vars); } else { $this->partial($layoutPath, $vars); } }