public function tree($id = null) {
		Configure::write('debug', 0);
		if (!method_exists($this->_model, 'getTreeData')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'getTreeData()',
				$this->_model->name
			));
		}
		if (!$this->_controller->request->is('ajax') || !$this->_controller->request->is('post') ||
			!$this->_controller->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [
			[
				'text' => __d('view_extension', '&lt;None&gt;'),
			]
		];
		$treeData = $this->_model->getTreeData($id);
		if (!empty($treeData)) {
			$data = $treeData;
		}
		$this->_controller->set(compact('data'));
		$this->_controller->set('_serialize', 'data');
	}
public function tree($id = null) {
		Configure::write('debug', 0);
		if (!method_exists($this->_model, 'getTreeData')) {
			throw new InternalErrorException(__d(
				'view_extension',
				'Method "%s" is not exists in model "%s"',
				'getTreeData()',
				$this->_model->name
			));
		}
		if (!$this->_controller->request->is('ajax') || !$this->_controller->request->is('post') ||
			!$this->_controller->RequestHandler->prefers('json')) {
			throw new BadRequestException();
		}

		$data = [
			[
				'text' => __d('view_extension', '&lt;None&gt;'),
			]
		];
		$treeData = $this->_model->getTreeData($id);
		if (!empty($treeData)) {
			$data = $treeData;
		}
		$this->_controller->set(compact('data'));
		$this->_controller->set('_serialize', 'data');
	}
public function tree ( $ id = null ) { Configure :: write ( 'debug' , 0 ) ; if ( ! method_exists ( $ this -> _model , 'getTreeData' ) ) { throw new InternalErrorException ( __d ( 'view_extension' , 'Method "%s" is not exists in model "%s"' , 'getTreeData()' , $ this -> _model -> name ) ) ; } if ( ! $ this -> _controller -> request -> is ( 'ajax' ) || ! $ this -> _controller -> request -> is ( 'post' ) || ! $ this -> _controller -> RequestHandler -> prefers ( 'json' ) ) { throw new BadRequestException ( ) ; } $ data = [ [ 'text' => __d ( 'view_extension' , '&lt;None&gt;' ) , ] ] ; $ treeData = $ this -> _model -> getTreeData ( $ id ) ; if ( ! empty ( $ treeData ) ) { $ data = $ treeData ; } $ this -> _controller -> set ( compact ( 'data' ) ) ; $ this -> _controller -> set ( '_serialize' , 'data' ) ; }
Return data for tree view

@param int|string $id ID for parent element of tree.
@throws InternalErrorException if method Model::getTreeData() is
not exists.
@throws BadRequestException if request is not AJAX, POST or JSON.
@return object Return response object of exported file.
Return data for tree view