. * */ namespace OCA\News\Controller; use \OCA\AppFramework\Controller\Controller; use \OCA\AppFramework\Core\API; use \OCA\AppFramework\Http\Request; use \OCA\News\Bl\FolderBl; class FolderController extends Controller { private $folderBl; public function __construct(API $api, Request $request, FolderBl $folderBl){ parent::__construct($api, $request); $this->folderBl = $folderBl; } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax * * Returns all folders */ public function getAll(){ $folders = $this->folderBl->findAll($this->api->getUserId()); $result = array( 'folders' => $folders ); return $this->renderJSON($result); } /** * @IsAdminExemption * @IsSubAdminExemption * @Ajax * * Collapses a folder */ public function collapse(){ $folderId = (int) $this->params('folderId'); try { $this->folderMapper->setCollapsed($folderId, true); return $this->renderJSON(array()); } catch (DoesNotExistException $e) { return $this->renderJSON(array(), $e->getMessage()); } catch(MultipleObjectsReturnedException $e){ return $this->renderJSON(array(), $e->getMessage()); } } }