예제 #1
0
 public function testAddChildInitialized()
 {
     $this->object->initialize();
     $mockModule1 = $this->getMockBuilder('\\Nethgui\\Controller\\AbstractController')->getMock();
     $mockModule1->expects($this->once())->method('isInitialized')->will($this->returnValue(FALSE));
     $mockModule1->expects($this->once())->method('initialize');
     $mockModule1->expects($this->once())->method('setParent');
     $this->object->addChild($mockModule1);
 }
예제 #2
0
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     foreach ($this->getChildren() as $child) {
         $innerView = $view->spawnView($child, TRUE);
         $child->prepareView($innerView);
     }
 }
 /**
  * Display all actions in a disabled state if current action is not defined,
  * otherwise display the current action only.
  * 
  * @param \Nethgui\View\ViewInterface $view
  */
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     parent::prepareView($view);
     if (is_null($this->currentAction)) {
         // Prepare an unobstrusive view of each child. The first one is
         // shown to the user.
         $view->setTemplate(array($this, 'renderIndex'));
         foreach ($this->getChildren() as $childModule) {
             $innerView = $view->spawnView($childModule, TRUE);
             $childModule->prepareView($innerView);
         }
     } elseif ($this->currentAction instanceof \Nethgui\View\ViewableInterface) {
         $view->setTemplate(array($this, 'renderCurrentAction'));
         // Spawn and prepare the view for the current action:
         $innerView = $view->spawnView($this->currentAction, TRUE);
         $this->currentAction->prepareView($innerView);
         // Optimize next view for valid requests:
         if ($this->getRequest()->isValidated()) {
             $this->prepareNextViewOptimized($view);
         }
     }
 }