/**
  * Retrieve the Controller instance that matches the Route instance.
  * @return \Puzzlout\Framework\Controllers\BaseController the Controller object
  */
 public function getController()
 {
     $router = new Router($this);
     $router->setCurrentRoute();
     $controllerObject = $this->GetControllerObject($router);
     $this->controller = $controllerObject;
     return $controllerObject;
 }
Esempio n. 2
0
 public function GetResourceObject()
 {
     $context = new \Puzzlout\Framework\Core\Context($this->app);
     $route = \Puzzlout\Framework\Core\Router::Init($this->app)->currentRoute();
     $culture = $context->GetCultureLang() . "_" . $context->GetCultureRegion();
     $resxController = new \Puzzlout\Framework\Core\ResourceManagers\ControllerResxBase($this->app);
     $resxController->Instantiate(array(\Puzzlout\Framework\Core\ResourceManagers\ResourceBase::ModuleKey => $route->module(), \Puzzlout\Framework\Core\ResourceManagers\ResourceBase::ActionKey => $route->action(), \Puzzlout\Framework\Core\ResourceManagers\ResourceBase::CultureKey => $culture));
     return $resxController;
 }
 /**
  * Find the controller class name to instanciate.
  * 
  * @param string $controllerName : the controller to find
  * @param string $FrameworkControllersListClass : class name to the list of framework controllers list
  * @param string $ApplicationControllersListClass : class name to the list of current application controllers list
  * @param \Puzzlout\Framework\Core\Route $route : the current route
  */
 public function FindControllerClassName($controllerName, $FrameworkControllers, $ApplicationControllers, \Puzzlout\Framework\Core\Router $router)
 {
     $FrameworkControllers = $FrameworkControllers::GetList();
     $ApplicationControllers = $ApplicationControllers::GetList();
     $controllerClass = "\\Puzzlout\\Framework\\Controllers\\ErrorController";
     if (array_key_exists($controllerName, $FrameworkControllers)) {
         $frameworkCtrlFolderPath = NameSpaceName::LibFolderName . NameSpaceName::LibControllersFolderName;
         $controllerClass = $frameworkCtrlFolderPath . $controllerName;
         $router->isWsCall = true;
     } else {
         if (array_key_exists($controllerName, $ApplicationControllers)) {
             $appCtrlFolderPath = NameSpaceName::AppsFolderName . "\\" . $this->name . NameSpaceName::AppsControllersFolderName;
             $controllerClass = $appCtrlFolderPath . $controllerName;
         } else {
             error_log("The controller requested '{$controllerClass}' doesn't exist.");
             $router->currentRoute()->setModule("Error");
             $router->currentRoute()->setAction("ControllerNotFound");
         }
     }
     return $controllerClass;
 }
 /**
  * Add the context the variables that are used to generated the output from the Views.
  */
 public function AddGlobalAppVariables()
 {
     $context = new Context($this->app);
     $culture = $context->GetCultureLang() . "_" . $context->GetCultureRegion();
     $this->page()->addVar('culture', $culture);
     $user = $this->app()->user->getAttribute(\Puzzlout\Framework\Enums\SessionKeys::UserConnected);
     $this->page()->addVar('user', $user[0]);
     $this->page()->addVar(Router::CurrentRouteVarKey, Router::Init($this->app)->currentRoute());
 }
 /**
  * 
  * @param string $key
  * @return string
  */
 public function getControllerResx($key)
 {
     $route = Router::Init($this->app)->currentRoute();
     $resource = $this->ControllerResources[$this->context->GetCultureID()][$route->module()][$route->action()][$key][F_controller_resource::F_CONTROLLER_RESOURCE_VALUE];
     return $resource;
 }