. * */ namespace OCA\News\Bl; use \OCA\News\Db\Item; use \OCA\News\Db\ItemMapper; class ItemBl extends Bl { public function __construct(ItemMapper $itemMapper){ parent::__construct($itemMapper); } public function findAllNew($id, $type, $updatedSince, $userId){ // TODO all the crazy finding of items } public function findAll($id, $type, $limit, $offset, $userId){ // TODO all the crazy finding of items } public function starredCount($userId){ return $this->mapper->starredCount($userId); } public function star($itemId, $isStarred, $userId){ $item = $this->find($itemId, $userId); if($isStarred){ $item->setStarred(); } else { $item->setUnstarred(); } $this->mapper->update($item); } public function read($itemId, $isRead, $userId){ $item = $this->find($itemId, $userId); if($isRead){ $item->setRead(); } else { $item->setUnread(); } $this->mapper->update($item); } public function readFeed($feedId, $userId){ $this->mapper->readFeed($feedId, $userId); } // ATTENTION: this does no validation and is only for creating // items from the fetcher public function create($item){ $this->mapper->insert($item); } }