/** * @load * @param ReflectionMethod $reflection */ protected function _createFromReflection($reflection) { $this->_type = Method::ControllerMethod; parent::_createFromReflection($reflection); //{ Add Views if ($this->isPublic()) { $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name()); if (file_exists($viewPath)) { $this->setViewDirectoryCreated(); $dh = opendir($viewPath); $viewsFound = array(); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') { $viewFilePath = rtrim($viewPath, '/') . "/{$file}"; if ($file == 'layout.php') { $this->setHasLayout(); $this->_layout = ControllerLayout::create($viewPath . '/layout.php'); } else { if ($file == 'params.php') { $this->setHasParams(); $this->_params = Params::create($viewPath . '/params.php'); } else { $viewsFound[$file] = $viewFilePath; $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME))); } } } } closedir($dh); if (array_key_exists('view.php', $viewsFound)) { $this->setHasDefaultView(); } } } //} }
/** * @load * @param ReflectionMethod $reflection */ private function _createFromReflection($reflection) { $this->_name = $reflection->getName(); $this->_public = $reflection->isPublic(); $this->_inherited = !($reflection->getDeclaringClass()->getName() == $this->_controller->className()); foreach ($reflection->getParameters() as $paramReflection) { //Argument::create($this, $paramReflection); $this->addArgument(Argument::create($this, $paramReflection)); } //{ Add Views if ($this->isAction()) { $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name()); if (file_exists($viewPath)) { $this->setViewDirectoryCreated(); $dh = opendir($viewPath); $viewsFound = array(); while (false !== ($file = readdir($dh))) { if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') { $viewFilePath = rtrim($viewPath, '/') . "/{$file}"; if ($file == 'layout.php') { $this->setHasLayout(); } else { if ($file == 'params.php') { $this->setHasParams(); } else { $viewsFound[$file] = $viewFilePath; $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME))); } } } } closedir($dh); if (array_key_exists('view.php', $viewsFound)) { $this->setHasDefaultView(); } } } //} }