From 39aa8530424310663c888f9e02224158961532e3 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Tue, 30 Oct 2018 18:41:29 +0100 Subject: PHP is crap --- api/Posts/Services/PostService.php | 87 -------------------------------------- 1 file changed, 87 deletions(-) delete mode 100644 api/Posts/Services/PostService.php (limited to 'api/Posts/Services/PostService.php') diff --git a/api/Posts/Services/PostService.php b/api/Posts/Services/PostService.php deleted file mode 100644 index 0232af2..0000000 --- a/api/Posts/Services/PostService.php +++ /dev/null @@ -1,87 +0,0 @@ -auth = $auth; - $this->database = $database; - $this->dispatcher = $dispatcher; - $this->postRepository = $postRepository; - } - - public function getAll($options = []) - { - return $this->postRepository->getJoined($options); - } - - public function getById($postId, array $options = []) - { - $post = $this->getRequestedPost($postId); - - return $post; - } - - public function create($data) - { - $post = $this->postRepository->create($data); - - $this->dispatcher->fire(new PostWasCreated($post)); - - return $post; - } - - public function update($postId, array $data) - { - $post = $this->getRequestedPost($postId); - - $this->postRepository->update($post, $data); - - $this->dispatcher->fire(new PostWasUpdated($post)); - - return $post; - } - - public function delete($postId) - { - $post = $this->getRequestedPost($postId); - - $this->postRepository->delete($postId); - - $this->dispatcher->fire(new PostWasDeleted($post)); - } - - private function getRequestedPost($postId) - { - $post = $this->postRepository->getJoinedById($postId); - - if (is_null($post)) { - throw new PostNotFoundException(); - } - - return $post; - } -} -- cgit v1.2.3