Ejemplo n.º 1
0
 /**
  * Uses the route detail to detemine if the view is disabled, also
  * checks the data type of the view. Eventhough, ViewInterface implements
  * __toString, it has the possibility of throwing exceptions which in
  * __toString leaves a nasty little error that says simply, you can
  * not throw exceptions in __toString. To avoid this we run build instead
  *
  * @param	MvcContextInterface $context
  * @param	MvcRouteDetailInterface $route
  * @return	string
  */
 public function composeView(MvcContextInterface $context, MvcRouteDetailInterface $route)
 {
     if (!$route->isView()) {
         return '';
     }
     $view = $context->getView();
     if (is_string($view)) {
         $result = $view;
     } else {
         if ($view instanceof ViewInterface) {
             $result = $view->build();
         } else {
             if (is_callable(array($view, '__toString'))) {
                 $result = (string) $view;
             } else {
                 $err = "view must be a string or an object the implements ";
                 $err .= "Appfuel\\View\\ViewInterface or an object thtat implemnts ";
                 $err .= "__toString";
                 throw new DomainException($err);
             }
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 /**
  * Startup tasks allow developers to write intialization strategies and
  * register them in the config. We collection all the strategies and 
  * execute them one at a time, storing the resulting status string in 
  * out static collection of status results.
  *  
  * @return	null
  */
 public function runStartupTasks(MvcRouteDetailInterface $route = null)
 {
     $manager = new StartupManager();
     $tasks = $manager->getTasksFromRegistry();
     if (null === $route) {
         $manager->runTasks($tasks);
         return $this;
     }
     $routeTasks = $route->getStartupTasks();
     if ($route->isIgnoreConfigStartupTasks()) {
         $manager->runTasks($routeTasks);
         return $this;
     }
     if ($route->isExcludedStartupTasks()) {
         $tasks = array_diff($tasks, $route->getExcludedStartupTasks());
     }
     if ($route->isPrependStartupTasks()) {
         $tasks = array_merge($routeTasks, $tasks);
     } else {
         $tasks = array_merge($tasks, $routeTasks);
     }
     $manager->runTasks($tasks);
     return $this;
 }