Esempio n. 1
0
 /**
  * Create a tree states instance.
  *
  * @return TreeNodeStates
  */
 public function getTreeNodeStates()
 {
     if (!isset($this->nodeStates)) {
         $environment = $this->getEnvironment();
         $sessionStorage = $environment->getSessionStorage();
         $this->nodeStates = new TreeNodeStates($sessionStorage->get($this->getToggleId()), $this->determineParentsOfValues());
         // Maybe it is not the best location to do this here.
         if ($environment->getInputProvider()->getParameter('ptg') == 'all') {
             // Save in session and reload.
             $sessionStorage->set($this->getToggleId(), $this->nodeStates->setAllOpen($this->nodeStates->isAllOpen())->getStates());
             $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_RELOAD, new ReloadEvent());
         }
     }
     return $this->nodeStates;
 }