public function Init($source = \Puzzlout\Framework\Core\ResourceManagers\ResourceBase::FROM_DB) { $dal = $this->app()->dal()->getDalInstance(); switch ($source) { case ResourceManagers\ResourceBase::FROM_DB: $logGuid = \Puzzlout\Framework\Utility\TimeLogger::StartLogInfo($this->app(), __CLASS__ . __METHOD__); $objectLists = array(); $objectLists[self::COMMON_RESX_OBJ_LIST] = $dal->selectMany(new \Puzzlout\Framework\BO\F_common_resource(), new \Puzzlout\Framework\Dal\DbQueryFilters()); $objectLists[self::CONTROLLER_RESX_OBJ_LIST] = $dal->selectMany(new \Puzzlout\Framework\BO\F_controller_resource(), new \Puzzlout\Framework\Dal\DbQueryFilters()); $this->OrganizeResourcesIntoAssociativeArray($objectLists); \Puzzlout\Framework\Utility\TimeLogger::EndLog($this->app, $logGuid); break; default: //todo: create error code throw new \Exception("Source " . $source . " is not implemented", 0, null); } }
/** * Execute the Controller action. * * @return \Puzzlout\Framework\ViewModels\BaseVm The output View Model * @throws \RuntimeException Handle the non-existing action in the current controller */ public function execute() { $action = $this->action(); if (!is_callable(array($this, $action))) { $errorMessage = 'The action <b>' . $this->action . '</b> is not defined for the module <b>' . ucfirst($this->module) . '</b>'; throw new \RuntimeException($errorMessage, MvcErrors::ACTION_NOT_FOUND_FOR_CONTROLLER, null); } $logGuid = \Puzzlout\Framework\Utility\TimeLogger::StartLogInfo($this->app(), get_class($this) . "->" . ucfirst($action)); $viewModelObject = $this->{$action}(); \Puzzlout\Framework\Utility\TimeLogger::EndLog($this->app(), $logGuid); return $viewModelObject; }