diff options
Diffstat (limited to 'bl')
-rw-r--r-- | bl/feedbl.php | 33 | ||||
-rw-r--r-- | bl/folderbl.php | 38 |
2 files changed, 71 insertions, 0 deletions
diff --git a/bl/feedbl.php b/bl/feedbl.php new file mode 100644 index 000000000..43e0faf6f --- /dev/null +++ b/bl/feedbl.php @@ -0,0 +1,33 @@ +<?php + +namespace OCA\News; + +class FeedBl { + + public function __construct($feedMapper){ + $this->feedMapper = $feedMapper; + } + + public function getAll() { + return $this->feedMapper->findAll(); + } + + public function getById($feedid) { + return $this->feedMapper->findById($feedid); + } + + public function delete($feedid) { + return $this->feedMapper->deleteById($feedid); + } + + public function create($url, $folderid) { + $feed = new Feed($url); + $this->feedMapper->save($feed, $folderid); + $feed = Utils::fetch($url); + if ($feed != null) { + $this->feedMapper->save($feed, $folderid); + } + return true; + } + +} diff --git a/bl/folderbl.php b/bl/folderbl.php new file mode 100644 index 000000000..85c386d90 --- /dev/null +++ b/bl/folderbl.php @@ -0,0 +1,38 @@ +<?php + +namespace OCA\News; + +class FolderBl { + + public function __construct($folderMapper){ + $this->folderMapper = $folderMapper; + } + + public function getAll() { + return $this->folderMapper->getAll(); + } + + public function create($name, $parentId) { + //TODO: change the setparentid in the model class Folder + $folder = new Folder($name, null, null); + return $this->folderMapper->save($folder); + } + + public function delete($folderid) { + return $this->folderMapper->deleteById($folderid); + } + + public function modify($folderid, $name = null, $parent = null, $opened = null) { + $folder = $this->folderMapper->find($folderid); + if(!$folder) + return false; + + if($name) + $folder->setName($name); + if($parent) + $folder->setParentId($parent); + if($opened) + $folder->setOpened($opened); + return $this->folderMapper->update($folder); + } +} |