TreeBranchAction.class.php (912B)
1 <?php 2 namespace cms\ui\action\tree; 3 use cms\ui\action\TreeAction; 4 use cms\action\Method; 5 use util\Tree; 6 7 class TreeBranchAction extends TreeAction implements Method { 8 public function view() { 9 10 $type = $this->request->getAlphanum('type'); 11 12 $branch = $this->loadTreeBranch( $type ); 13 14 $this->setTemplateVar( 'branch',$branch ); 15 } 16 17 18 public function post() { 19 } 20 21 22 protected function loadTreeBranch($type ) 23 { 24 $tree = new Tree(); 25 26 try 27 { 28 $method = new \ReflectionMethod($tree,$type); 29 if ( $id = $this->request->getId() ) 30 $method->invoke($tree, $id ); 31 else 32 $method->invoke($tree); // <== Executing the Action 33 } 34 catch (\ReflectionException $re) 35 { 36 throw new \LogicException('Treemethod not found: '.$type); 37 } 38 39 40 $branch = array(); 41 foreach($tree->treeElements as $element ) 42 { 43 $branch[] = get_object_vars($element); 44 } 45 46 return $branch; 47 } 48 49 }