/** * @return string */ public function controllerClass() { if (null === $this->module) { return \Nano\Names::applicationClass($this->controller, \Nano\Names::NAMESPACE_CONTROLLER); } return \Nano\Names::moduleClass($this->module, $this->controller, \Nano\Names::NAMESPACE_CONTROLLER); }
/** * @return \Nano\Helper * @param string $name * * @throws \Nano\Exception\HelperNotFound */ protected function search($name) { $className = \Nano\Names::helperClass($name, $this->module); $classPath = \Nano\Names::moduleFile($className); if (!$this->application->loader->loadFileWithClass($className, $classPath)) { throw new \Nano\Exception\HelperNotFound($name, $this->module); } return new $className(); }
/** * @return string * @param string $name * @param boolean $controller * @param string|null $module */ public static function formatName($name, $controller = true, $module = null) { if ($controller) { return \Nano\Names::controllerClass($name, $module); } $result = \Nano::stringToName($name); $result = strToLower($result[0]) . subStr($result, 1); $result .= self::SUFFIX_ACTION; return $result; }
/** * @return \Nano\Helper * @param string $name * * @throws \Nano\Exception\HelperNotFound */ protected function search($name) { $className = \Nano\Names::helperClass($name); if (class_exists($className, false)) { return $className; } $classPath = \Nano\Names::applicationFile($className); if (!\Nano::app()->loader->loadFileWithClass($className, $classPath)) { throw new \Nano\Exception\HelperNotFound($name); } return new $className(); }
/** * @return \Nano\Controller\Response\Test * @param \Nano\Application $application * @param string $module * @param string $controller * @param string $action * @param array $params */ protected static function runAction(\Nano\Application $application, $module, $controller, $action, array $params = array()) { /** @var \Nano\Controller $instance */ $className = null === $module ? \Nano\Names::applicationClass($controller, \Nano\Names::NAMESPACE_CONTROLLER) : \Nano\Names::moduleClass($module, $controller, \Nano\Names::NAMESPACE_CONTROLLER); $instance = new $className($application); $instance->setResponse(new \Nano\Controller\Response\Test($application)); $instance->setRenderer(new \Nano\Render($application)); $params['module'] = $module; $params['controller'] = $controller; $params['action'] = $action; $application->dispatcher->setParams($params); self::setObjectProperty($application->dispatcher, 'controllerInstance', $instance); $instance->run($action); return $instance->response(); }
public function testUsingHelperAdditionalNamespaceWithModuleNamespace() { self::assertEquals('Module\\Test\\Helper\\News\\Backend', \Nano\Names::helperClass('news/backend', 'test')); }
/** * @return string * @param string $name */ public static function nameToNamespace($name) { return \Nano\Names::common($name); }