summaryrefslogtreecommitdiffstats
path: root/service/service.php
diff options
context:
space:
mode:
Diffstat (limited to 'service/service.php')
-rw-r--r--service/service.php74
1 files changed, 37 insertions, 37 deletions
diff --git a/service/service.php b/service/service.php
index f3700de98..e53468828 100644
--- a/service/service.php
+++ b/service/service.php
@@ -21,42 +21,42 @@ use \OCA\News\Db\NewsMapper;
abstract class Service {
- protected $mapper;
-
- public function __construct(NewsMapper $mapper){
- $this->mapper = $mapper;
- }
-
-
- /**
- * Delete an entity
- * @param int $id the id of the entity
- * @param string $userId the name of the user for security reasons
- * @throws ServiceNotFoundException if the entity does not exist, or there
- * are more than one of it
- */
- public function delete($id, $userId){
- $entity = $this->find($id, $userId);
- $this->mapper->delete($entity);
- }
-
-
- /**
- * Finds an entity by id
- * @param int $id the id of the entity
- * @param string $userId the name of the user for security reasons
- * @throws ServiceNotFoundException if the entity does not exist, or there
- * are more than one of it
- * @return \OCP\AppFramework\Db\Entity the entity
- */
- public function find($id, $userId){
- try {
- return $this->mapper->find($id, $userId);
- } catch(DoesNotExistException $ex){
- throw new ServiceNotFoundException($ex->getMessage());
- } catch(MultipleObjectsReturnedException $ex){
- throw new ServiceNotFoundException($ex->getMessage());
- }
- }
+ protected $mapper;
+
+ public function __construct(NewsMapper $mapper){
+ $this->mapper = $mapper;
+ }
+
+
+ /**
+ * Delete an entity
+ * @param int $id the id of the entity
+ * @param string $userId the name of the user for security reasons
+ * @throws ServiceNotFoundException if the entity does not exist, or there
+ * are more than one of it
+ */
+ public function delete($id, $userId){
+ $entity = $this->find($id, $userId);
+ $this->mapper->delete($entity);
+ }
+
+
+ /**
+ * Finds an entity by id
+ * @param int $id the id of the entity
+ * @param string $userId the name of the user for security reasons
+ * @throws ServiceNotFoundException if the entity does not exist, or there
+ * are more than one of it
+ * @return \OCP\AppFramework\Db\Entity the entity
+ */
+ public function find($id, $userId){
+ try {
+ return $this->mapper->find($id, $userId);
+ } catch(DoesNotExistException $ex){
+ throw new ServiceNotFoundException($ex->getMessage());
+ } catch(MultipleObjectsReturnedException $ex){
+ throw new ServiceNotFoundException($ex->getMessage());
+ }
+ }
}