Exemple #1
0
 /**
  * @param	MvcContextInterface $context
  * @return	null
  */
 public function process(MvcContextInterface $context)
 {
     $input = $context->getInput();
     $view = $context->getView();
     if (!ResourceTreeManager::isTree()) {
         ResourceTreeManager::loadTree();
     }
     $finder = new FileFinder('resource');
     $writer = new FileWriter($finder);
     $reader = new FileReader($finder);
     if (!$writer->deleteTree('build', true)) {
         $err = "could not detete -({$finder->getPath('build')})";
         throw new RunTimeException($err);
     }
     $list = ResourceTreeManager::getAllPageNames();
     if (!is_array($list) || empty($list)) {
         return;
     }
     foreach ($list as $pageName) {
         $pkg = ResourceTreeManager::getPkg($pageName);
         $layers = $pkg->getLayers();
         $pageStack = new FileStack();
         foreach ($layers as $layerName) {
             $stack = new FileStack();
             $layer = ResourceTreeManager::loadLayer($layerName, $stack);
             $this->buildLayer($layer, $reader, $writer, $pageStack);
         }
         $this->buildLayer(ResourceTreeManager::createPageLayer($pageName), $reader, $writer, $pageStack);
         $themeName = $pkg->getThemeName();
         if ($themeName) {
             $this->buildTheme($themeName, $reader, $writer, $pageStack);
         }
     }
     $view->assign('result', 'build completed');
 }
 /**
  * @param   AppContextInterface           $context
  * @param   ConsoleViewTemplateInterface  $view
  * @return  mixed   null | AppContextInterface 
  */
 public function process(MvcContextInterface $context)
 {
     $view = $context->getView();
     $input = $context->getInput();
     $valueC = $input->get('get', 'label-c');
     $valueD = $input->get('get', 'label-d');
     $result = "processed label-a={$valueC} label-b={$valueD}";
     $view->assign('action-c:', $result);
 }
 /**
  * @param   AppContextInterface           $context
  * @param   ConsoleViewTemplateInterface  $view
  * @return  mixed   null | AppContextInterface 
  */
 public function process(MvcContextInterface $context)
 {
     $view = $context->getView();
     $input = $context->getInput();
     $valueA = $input->get('get', 'label-a');
     $valueB = $input->get('get', 'label-b');
     $result = "processed label-a={$valueA} label-b={$valueB}";
     $view->assign('action-b:', $result);
 }
 /**
  * @param	ContextInterface $context
  * @return	null
  */
 public function filter(MvcContextInterface $context)
 {
     $view = $context->getView();
     if (!$view instanceof ViewTemplateInterface) {
         $this->next($context);
     }
     $value = $view->get('my-assignment', '');
     $value = str_replace(' ', ':', $value);
     $view->assign('my-assignment', $value);
     $this->next($context);
 }
 /**
  * @param	ContextInterface $context
  * @return	null
  */
 public function filter(MvcContextInterface $context)
 {
     $view = $context->getView();
     $value = $view->get('my-assignment', false);
     if (false === $value) {
         return $this->next($context);
     }
     $value = '4 5 6 ' . $value;
     $view->assign('my-assignment', $value);
     $this->next($context);
 }
 /**
  * @param   AppContextInterface           $context
  * @param   ConsoleViewTemplateInterface  $view
  * @return  mixed   null | AppContextInterface 
  */
 public function process(MvcContextInterface $context)
 {
     $view = $context->getView();
     $params = array('get' => array('label-a' => 'value-a', 'label-b' => 'value-b'));
     $uriB = 'action-b/label-a/value-a/label-b/value-b';
     $uriC = 'action-c/label-c/value-c/label-d/value-d';
     $strategy = $context->getStrategy();
     $contextB = $this->callUri($uriB, $strategy);
     $contextC = $this->callUri($uriC, $strategy);
     $results = $contextB->buildView() . ' and ' . $contextC->buildView();
     $view->assign('results', $results);
 }
 /**
  * @param   AppContextInterface           $context
  * @param   ConsoleViewTemplateInterface  $view
  * @return  mixed   null | AppContextInterface 
  */
 public function process(MvcContextInterface $context)
 {
     $view = $context->getView();
     $label = 'my-assignment';
     $default = 'this action has been executed';
     $value = $view->get($label, null);
     if (!empty($value) && is_string($value)) {
         $value .= " {$default}";
     } else {
         $value = $default;
     }
     $view->assign($label, $value);
 }
 /**
  * @param   AppContextInterface           $context
  * @param   ConsoleViewTemplateInterface  $view
  * @return  mixed   null | AppContextInterface 
  */
 public function process(MvcContextInterface $context)
 {
     $strategy = $context->getStrategy();
     $view = $context->getView();
     $view->assign('common-a', 'value-a')->assign('common-b', 'value-b');
     switch ($strategy) {
         case 'console':
             $label = 'console-foo';
             break;
         case 'ajax':
             $label = 'ajax-foo';
             break;
         case 'html':
             $label = 'html-foo';
             break;
     }
     $view->assign($label, 'bar');
 }
Exemple #9
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;
 }
 /**
  * @param   MvcContextInterface $context
  * @return  null
  */
 public function process(MvcContextInterface $context)
 {
     $view = $context->getView();
     $view->assign('foo', 'bar');
 }
 /**
  * @param	ContextInterface $context
  * @return	null
  */
 public function filter(MvcContextInterface $context)
 {
     $view = $context->getView();
     $view->assign('my-assignment', 'value 1 2 3');
     $this->next($context);
 }