public function addChild(\Nethgui\Module\ModuleInterface $childModule)
 {
     if (isset($this->session) && $childModule instanceof \Nethgui\Utility\SessionConsumerInterface) {
         $childModule->setSession($this->getSession());
     }
     parent::addChild($childModule);
 }
 /**
  * Add a child module, propagating the adpater settings.
  * 
  * @api
  * @param \Nethgui\Module\ModuleInterface $childModule
  * @return array
  */
 public function addChild(\Nethgui\Module\ModuleInterface $childModule)
 {
     if ($this->hasAdapter() && $childModule instanceof AbstractAction) {
         $childModule->setAdapter($this->getAdapter());
     }
     return parent::addChild($childModule);
 }
 public function onParametersSaved(\Nethgui\Module\ModuleInterface $currentAction, $changes, $parameters)
 {
     $actionName = $currentAction->getIdentifier();
     if ($actionName === 'update') {
         $actionName = 'modify';
     }
     $this->getPlatform()->signalEvent(sprintf('host-%s &', $actionName));
 }
 /**
  * Create a new instance from basic module informations
  * 
  * @param \Nethgui\Module\ModuleInterface $module
  * @return SimpleModuleAttributesProvider 
  */
 public function initializeFromModule(\Nethgui\Module\ModuleInterface $module)
 {
     $i = $module->getIdentifier();
     $this->title = $i . '_Title';
     $this->description = $i . '_Description';
     $this->languageCatalog = strtr(get_class($module), '\\', '_');
     $this->tags = $i . '_Tags';
     return $this;
 }
 /**
  * Render callback.
  *
  * This is the view template callback function that forwards the
  * render message to the current action.
  *
  * Note: The current action template is wrapped inside a DIV.Action tag.
  *
  * @param \Nethgui\Renderer\Xhtml $view The view
  * @return string
  */
 public function renderCurrentAction(\Nethgui\Renderer\Xhtml $view)
 {
     $flags = $view::INSET_WRAP;
     if ($this->needsAutoFormWrap($this->currentAction)) {
         $flags |= $view::INSET_FORM;
     }
     return $view->inset($this->currentAction->getIdentifier(), $flags);
 }
Example #6
0
 public function bind(\Nethgui\Controller\RequestInterface $request)
 {
     parent::bind($request);
     $fileName = \Nethgui\array_head($request->getPath());
     if (preg_match('/[a-z][a-z0-9]+(.rst)/i', $fileName) == 0 && preg_match('/[a-z][a-z0-9]+(.html)/i', $fileName) == 0) {
         throw new \Nethgui\Exception\HttpException('Not found', 404, 1322148405);
     }
     // Now assuming a trailing ".rst" or ".html" suffix.
     if (substr($fileName, -3) == 'rst') {
         $this->module = $this->getModuleSet()->getModule(substr($fileName, 0, -4));
     } else {
         //html
         $this->module = $this->getModuleSet()->getModule(substr($fileName, 0, -5));
     }
     if (is_null($this->module)) {
         throw new \Nethgui\Exception\HttpException('Not found', 404, 1322148406);
     }
     $this->module->setPlatform($this->getPlatform());
     if (!$this->module->isInitialized()) {
         $this->module->initialize();
     }
 }
Example #7
0
 /**
  * Adds a child to Composite, initializing it, if current Composite is
  * initialized.
  *
  * @api
  * @param \Nethgui\Module\ModuleInterface $childModule
  * @return Composite
  */
 public function addChild(\Nethgui\Module\ModuleInterface $childModule)
 {
     if (isset($this->children[$childModule->getIdentifier()])) {
         throw new \LogicException(sprintf('%s: the module identifier "%s" is already registered as child!', __CLASS__, $childModule->getIdentifier()), 1322818691);
     }
     $this->children[$childModule->getIdentifier()] = $childModule;
     $childModule->setParent($this);
     if ($this->isInitialized() && !$childModule->isInitialized()) {
         call_user_func($this->dependencyInjector, $childModule);
         $childModule->initialize();
     }
     return $this;
 }
 protected function runModuleTest(\Nethgui\Module\ModuleInterface $module, ModuleTestEnvironment $env)
 {
     $platform = $this->createPlatformMock($env);
     $module->setPlatform($platform);
     $module->initialize();
     if ($module instanceof \Nethgui\Controller\RequestHandlerInterface) {
         $request = $this->createRequestMock($env);
         $validationReport = $this->createValidationReportMock($env);
         $module->bind($request);
         $module->validate($validationReport);
         $module->process();
     }
     $view = $this->createViewMock($module, $env);
     $module->prepareView($view);
     $platform->signalFinalEvents();
     foreach ($env->getView() as $key => $value) {
         $this->assertEquals($value, $view[$key], "View parameter `{$key}`.");
     }
     $this->fullViewOutput = array();
     // obsolete: $view->getClientEvents();
     foreach ($this->dbObjectCheckList as $dbStubInfo) {
         $this->assertTrue($dbStubInfo[1]->getState()->isFinal(), sprintf('Database `%s` is not in final state! %s', $dbStubInfo[0], $dbStubInfo[1]->getState()));
     }
 }
Example #9
0
 public function spawnView(\Nethgui\Module\ModuleInterface $module, $register = FALSE)
 {
     $spawnedView = new static($this->targetFormat, $module, $this->translator, $this->urlParts);
     $spawnedView->commands = $this->getCommands();
     if ($register === TRUE) {
         $this[$module->getIdentifier()] = $spawnedView;
     } elseif (is_string($register)) {
         $this[$register] = $spawnedView;
     }
     return $spawnedView;
 }
 public function getSuccessor(\Nethgui\Module\ModuleInterface $m)
 {
     $successor = NULL;
     $pos = $this->getStepList();
     while ($child = array_shift($pos)) {
         if ($m->getIdentifier() === $child->getIdentifier()) {
             $successor = array_shift($pos);
             break;
         }
     }
     return $successor;
 }
 /**
  * Add $childAction to the TableController, and propagate the table adapter, 
  * if it has not been done yet.
  * 
  * @param \Nethgui\Module\ModuleInterface $childAction 
  */
 public function addChild(\Nethgui\Module\ModuleInterface $childAction)
 {
     if ($childAction instanceof \Nethgui\Controller\Table\AbstractAction) {
         if ($childAction instanceof \Nethgui\Controller\Table\AbstractAction && !$childAction->hasAdapter()) {
             $childAction->setAdapter($this->getAdapter());
         }
     }
     return parent::addChild($childAction);
 }