diff options
author | Alessandro Cosentino <cosenal@gmail.com> | 2013-03-06 10:27:50 +0100 |
---|---|---|
committer | Alessandro Cosentino <cosenal@gmail.com> | 2013-03-06 10:27:50 +0100 |
commit | 3c87c2be39c609a3d68c133358ab91a40480b745 (patch) | |
tree | 0fa508a1552c34ef55ab9cfbd175d2fc5af4c8f6 /external_api | |
parent | c4349e0c2ee6a6600b8e661e776c2e1a4b131e0e (diff) |
api calls are anonymous functions now
Diffstat (limited to 'external_api')
-rw-r--r-- | external_api/feed.php | 29 | ||||
-rw-r--r-- | external_api/folder.php | 18 |
2 files changed, 20 insertions, 27 deletions
diff --git a/external_api/feed.php b/external_api/feed.php index fcdfd2c7f..7dfd5763f 100644 --- a/external_api/feed.php +++ b/external_api/feed.php @@ -4,16 +4,14 @@ namespace OCA\News; use \OCA\News\Controller\FeedController; -class API_Feed { +class FeedApi { -// public __construct($feedbl) { -// $this->bl = $feedbl; -// } + public function __construct($bl){ + $this->bl = $bl; + } - public static function getAll() { - $container = createDIContainer(); - $bl = $container['FeedBL']; - $feeds = $bl->getAll(); + public function getAll() { + $feeds = $this->bl->getAll(); $serializedFeeds = array(); foreach ($feeds as $feed) { $serializedFeeds[] = $feed->jsonSerialize(); @@ -21,23 +19,18 @@ class API_Feed { return new \OC_OCS_Result($serializedFeeds); } - public function getById($parameters) { - $feedid = $parameters['feedid']; - $container = createDIContainer(); - $bl = $container['FeedBL']; - $feed = $bl->getById($feedid); + public function getById($params) { + $feed = $this->bl->getById($feedid); $serializedFeed = array($feed->jsonSerialize()); return new \OC_OCS_Result($serializedFeed); } - public static function create() { - + public function create() { $url = $_POST['url']; $folderId = $_POST['folderid']; + //TODO: check parameters here - $container = createDIContainer(); - $bl = $container['FeedBL']; - $success = $bl->create($url, $folderId); + $success = $this->bl->create($url, $folderId); if ($success) { return new \OC_OCS_Result(); diff --git a/external_api/folder.php b/external_api/folder.php index f9dae7535..66e5f3915 100644 --- a/external_api/folder.php +++ b/external_api/folder.php @@ -4,12 +4,14 @@ namespace OCA\News; use \OCA\News\Controller\FolderController; -class API_Folder { +class FolderApi { - public static function getAll() { - $container = createDIContainer(); - $bl = $container['FolderBL']; - $folders = $bl->getAll(); + public function __construct($bl){ + $this->bl = $bl; + } + + public function getAll() { + $folders = $this->bl->getAll(); $serializedFolders = array(); //TODO: check the behaviour for nested folders @@ -19,14 +21,12 @@ class API_Folder { return new \OC_OCS_Result($serializedFolders); } - public static function create() { + public function create() { $name = $_POST['name']; $parentId = $_POST['parentid']; - $container = createDIContainer(); - $bl = $container['FolderBL']; - $bl->create($name, $parentId); + $this->bl->create($name, $parentId); return new \OC_OCS_Result(); } |