/** * 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; }
/** * Check the state of a model and set the metadata accordingly. * * @param ModelInterface $model The model of which the state shall be checked of. * * @param int $level The tree level the model is contained within. * * @return void */ private function determineModelState(ModelInterface $model, $level) { $model->setMeta(DCGE::TREE_VIEW_LEVEL, $level); $model->setMeta($model::SHOW_CHILDREN, $this->states->isModelOpen($model->getProviderName(), $model->getId())); }
/** * Save a tree node states instance to the session. * * @param TreeNodeStates $states The instance to be saved. * * @return void */ protected function saveTreeNodeStates(TreeNodeStates $states) { $sessionStorage = $this->getEnvironment()->getSessionStorage(); $sessionStorage->set($this->getToggleId(), $states->getStates()); }