public function run(DataContainerInterface $applicationData)
 {
     $dataContainerKey = 'request';
     $controllerKey = 'ctrl';
     $actionKey = 'act';
     $basePath = $applicationData->get('config')->get('viewDispatcherPath', '.');
     $controller = $applicationData->get($dataContainerKey)->get($controllerKey);
     $action = $applicationData->get($dataContainerKey)->get($actionKey);
     if (empty($controller) || empty($action)) {
         throw new ApplicationLayerException($this);
     }
     //data for the view
     $data = $applicationData->get('vars');
     $scriptName = ucfirst($controller) . ucfirst($action);
     $fileName = $basePath . '/' . ucfirst($controller) . '/' . $scriptName . '.php';
     if (!file_exists($fileName)) {
         throw new ApplicationLayerException($this, "Cannot find view file : {$fileName}");
     }
     ob_start();
     require $fileName;
     $content = ob_get_clean();
     $fileName = $basePath . '/layout.php';
     if (!file_exists($fileName)) {
         throw new ApplicationLayerException($this, "Cannot find layout file : {$fileName}");
     }
     require $fileName;
 }
 /**
  * Get a value by the key of this object
  *
  * @param string $key The key of the value
  * @return mixed The value
  */
 public function get($key)
 {
     try {
         return $this->container->get($key);
     } catch (AccessException $e) {
         throw new AccessException('"' . $key . '" doesn\'t exist in Relationship.');
     }
 }
 public function run(DataContainerInterface $applicationData)
 {
     $dao = new ArticleDaoFileSystem('blog/content/');
     $list = new ArticleList();
     $dao->loadAll($list);
     $hash = $applicationData->get('request')->get('article');
     $applicationData->get('vars')->set('article', $list->getByHash($hash));
 }
Example #4
0
 /**
  * Get a value by the key of this object
  *
  * @param string $key The key of the value
  * @return mixed The value
  */
 public function get($key)
 {
     try {
         return $this->container->get($key);
     } catch (AccessException $e) {
         throw new AccessException('"' . $key . '" doesn\'t exist in this jsonapi object.');
     }
 }
 public function run(DataContainerInterface $applicationData)
 {
     $dataContainerKey = 'request';
     $controllerKey = 'ctrl';
     $actionKey = 'act';
     $this->basePath = $applicationData->get('config')->get('controllerDispatcherPath', '.');
     $controller = $applicationData->get($dataContainerKey)->get($controllerKey);
     $action = $applicationData->get($dataContainerKey)->get($actionKey);
     if (empty($controller) || empty($action)) {
         throw new ApplicationLayerException($this, "Controller (<{$controllerKey}>) and/or action (<{$action}>) is not set in dataContainer (<{$dataContainerKey}>).");
     }
     $this->currentApplicationData = $applicationData;
     $this->getControllerInstance($controller, $action)->run($applicationData);
 }
 public function run(DataContainerInterface $applicationData)
 {
     $applicationData->get('vars')->set('title', $applicationData->get('config')->get('application_name'));
     $applicationData->get('vars')->append('message', 'hello from the controller !');
     $this->callController('Another', 'Thing');
 }
 public function run(DataContainerInterface $applicationData)
 {
     $applicationData->get('vars')->append('message', 'hello from the 2nd controller !');
 }