From 165540d34652fb895cb7f29c818fb3427bfba8c4 Mon Sep 17 00:00:00 2001 From: Alessandro Cosentino Date: Sat, 2 Mar 2013 16:21:50 +0100 Subject: [PATCH] prototype of business layer for api --- appinfo/bootstrap.php | 11 +++++++++++ appinfo/routes.php | 12 ++++++++++++ db/foldermapper.php | 9 +++++++++ external_api/folder.php | 15 +++++++++++++++ folder.bl.php | 14 ++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 external_api/folder.php create mode 100644 folder.bl.php diff --git a/appinfo/bootstrap.php b/appinfo/bootstrap.php index 72423c399..4bebf20f8 100644 --- a/appinfo/bootstrap.php +++ b/appinfo/bootstrap.php @@ -46,6 +46,10 @@ namespace OCA\News; \OC::$CLASSPATH['OCA\News\NewsController'] = 'apps/news/controller/news.controller.php'; \OC::$CLASSPATH['OCA\News\NewsAjaxController'] = 'apps/news/controller/news.ajax.controller.php'; +\OC::$CLASSPATH['OCA\News\FolderBL'] = 'apps/news/folder.bl.php'; + +\OC::$CLASSPATH['OCA\News\API_Folder'] = 'apps/news/external_api/folder.php'; + /** * @return a new DI container with prefilled values for the news app @@ -106,5 +110,12 @@ function createDIContainer(){ $c['FolderMapper'], $c['ItemMapper']); }; + /** + * BUSINESS LAYER OBJECTS + */ + $newsContainer['FolderBL'] = function($c){ + return new FolderBL($c['FolderMapper']); + }; + return $newsContainer; } \ No newline at end of file diff --git a/appinfo/routes.php b/appinfo/routes.php index 21c1de90d..9d232819a 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -200,3 +200,15 @@ $this->create('news_ajax_importOPML', '/import')->action( callAjaxController('NewsAjaxController', 'uploadOPML', $params); } ); + + +/** + * External API for folders + */ +\OCP\API::register( + 'get', + '/news/folders', + array('OCA\News\API_Folder ', 'getAll'), + 'news', + \OC_API::USER_AUTH +); diff --git a/db/foldermapper.php b/db/foldermapper.php index 5d7145176..5c1cd1552 100644 --- a/db/foldermapper.php +++ b/db/foldermapper.php @@ -53,6 +53,15 @@ class FolderMapper { return $folderlist; } + + /** + * @brief Returns the forest (list of trees) of folders children of $parentid + * @param + * @returns + */ + public function getAll() { + return self::childrenOf(0); + } /** * @brief Returns the forest (list of trees) of folders children of $parentid, diff --git a/external_api/folder.php b/external_api/folder.php new file mode 100644 index 000000000..5a3f70328 --- /dev/null +++ b/external_api/folder.php @@ -0,0 +1,15 @@ +getAll()); + } +} + diff --git a/folder.bl.php b/folder.bl.php new file mode 100644 index 000000000..b008f1dde --- /dev/null +++ b/folder.bl.php @@ -0,0 +1,14 @@ +folderMapper = $folderMapper; + } + + public static function getAll() { + $folders = $this->folderMapper->getAll(); + } +}