/**
  * Makes the AJAX call to expand or collapse the pagetree.
  * Called by typo3/ajax.php
  *
  * @param array $params Additional parameters (not used here)
  * @param \TYPO3\CMS\Core\Http\AjaxRequestHandler $ajaxObj The AjaxRequestHandler object of this request
  * @return void
  */
 public function ajaxExpandCollapse($params, $ajaxObj)
 {
     $this->init();
     $tree = $this->pagetree->getBrowsableTree();
     if (!$this->pagetree->ajaxStatus) {
         $ajaxObj->setError($tree);
     } else {
         $ajaxObj->addContent('tree', $tree);
     }
 }
 /**
  * Makes the AJAX call to expand or collapse the pagetree.
  * Called by an AJAX Route, see AjaxRequestHandler
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function ajaxExpandCollapse(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->init();
     $tree = $this->pagetree->getBrowsableTree();
     if (!$this->pagetree->ajaxStatus) {
         $response = $response->withStatus(500);
     } else {
         $response->getBody()->write(json_encode($tree));
     }
     return $response;
 }