GitHub PullRequestReviewCommentEvent at 2014-11-12 20:07:11
Repository: bookshelf
Actor: DmitryLanda
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/comments/20246762","id":20246762,"diff_hunk":"@@ -104,32 +85,45 @@ public function addAction()\n     public function updateAction()\r\n     {\r\n         $book = Book::find($this->request->get('id'));\r\n-        $errors = [];\r\n \r\n-        if ($this->request->isPost()) {\r\n-            $errors = $this->fillAndValidate($book);\r\n+        if (!$book) {\r\n+            $this->addErrorMessage('Редактируемая книга не найдена!');\r\n \r\n-            if (!$errors) {\r\n-                $book->save();\r\n+            $this->redirectTo('/books');\r\n+        } else {\r\n+            $errors = [];\r\n+            if ($this->request->isPost()) {\r\n+                $errors = $this->fillAndValidate($book);\r\n+\r\n+                if (!$errors) {\r\n+                    $book->save();\r\n+                    $this->addSuccessMessage('Книга успешно отредактирована!');\r\n \r\n-                return header('Location: /books');\r\n+                    $this->redirectTo('/books');\r\n+                }\r\n             }\r\n-        }\r\n \r\n-        return $this->templater->show($this->controllerName, 'Update', [\r\n-            'errors' => $errors,\r\n-            'categories' => Category::findAll(),\r\n-            'book' => $book,\r\n-            'availableAuthors' => $this->getAvailableAuthors()\r\n-        ]);\r\n+            return $this->render($this->controllerName, 'Update', [\r\n+                'errors' => $errors,\r\n+                'categories' => Category::findAll(),\r\n+                'book' => $book,\r\n+                'availableAuthors' => $this->getAvailableAuthors()\r\n+            ]);\r\n+        }\r\n     }\r\n \r\n     public function deleteAction()\r\n     {\r\n         $book = Book::find($this->request->get('id'));\r\n-        $book->delete();\r\n \r\n-        return header('Location: /books');\r\n+        if (!$book) {\r\n+            $this->addErrorMessage('Удаляемая книга не найдена!');\r\n+        } else {\r","path":"src/Bookshelf/Controller/BooksController.php","position":127,"original_position":127,"commit_id":"a20bc6aa4b56be77b134bde5edbc2e0b4ee70506","original_commit_id":"a20bc6aa4b56be77b134bde5edbc2e0b4ee70506","user":{"login":"DmitryLanda","id":1225610,"avatar_url":"https://avatars.githubusercontent.com/u/1225610?v=3","gravatar_id":"","url":"https://api.github.com/users/DmitryLanda","html_url":"https://github.com/DmitryLanda","followers_url":"https://api.github.com/users/DmitryLanda/followers","following_url":"https://api.github.com/users/DmitryLanda/following{/other_user}","gists_url":"https://api.github.com/users/DmitryLanda/gists{/gist_id}","starred_url":"https://api.github.com/users/DmitryLanda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DmitryLanda/subscriptions","organizations_url":"https://api.github.com/users/DmitryLanda/orgs","repos_url":"https://api.github.com/users/DmitryLanda/repos","events_url":"https://api.github.com/users/DmitryLanda/events{/privacy}","received_events_url":"https://api.github.com/users/DmitryLanda/received_events","type":"User","site_admin":false},"body":"why?\r\nWe just add an error message in case of book not found\r\n\r\nredirect will be called later\r\non 126 line","created_at":"2014-11-12T20:07:11Z","updated_at":"2014-11-12T20:07:11Z","html_url":"https://github.com/bakulinav/bookshelf/pull/24#discussion_r20246762","pull_request_url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24","_links":{"self":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/comments/20246762"},"html":{"href":"https://github.com/bakulinav/bookshelf/pull/24#discussion_r20246762"},"pull_request":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24"}}},"pull_request":{"url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24","id":24292139,"html_url":"https://github.com/bakulinav/bookshelf/pull/24","diff_url":"https://github.com/bakulinav/bookshelf/pull/24.diff","patch_url":"https://github.com/bakulinav/bookshelf/pull/24.patch","issue_url":"https://api.github.com/repos/bakulinav/bookshelf/issues/24","number":24,"state":"open","locked":false,"title":"Add flash messages","user":{"login":"danilms","id":7677641,"avatar_url":"https://avatars.githubusercontent.com/u/7677641?v=3","gravatar_id":"","url":"https://api.github.com/users/danilms","html_url":"https://github.com/danilms","followers_url":"https://api.github.com/users/danilms/followers","following_url":"https://api.github.com/users/danilms/following{/other_user}","gists_url":"https://api.github.com/users/danilms/gists{/gist_id}","starred_url":"https://api.github.com/users/danilms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danilms/subscriptions","organizations_url":"https://api.github.com/users/danilms/orgs","repos_url":"https://api.github.com/users/danilms/repos","events_url":"https://api.github.com/users/danilms/events{/privacy}","received_events_url":"https://api.github.com/users/danilms/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-11-12T13:32:36Z","updated_at":"2014-11-12T20:07:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24/commits","review_comments_url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24/comments","review_comment_url":"https://api.github.com/repos/bakulinav/bookshelf/pulls/comments/{number}","comments_url":"https://api.github.com/repos/bakulinav/bookshelf/issues/24/comments","statuses_url":"https://api.github.com/repos/bakulinav/bookshelf/statuses/a20bc6aa4b56be77b134bde5edbc2e0b4ee70506","head":{"label":"danilms:flash_messages","ref":"flash_messages","sha":"a20bc6aa4b56be77b134bde5edbc2e0b4ee70506","user":{"login":"danilms","id":7677641,"avatar_url":"https://avatars.githubusercontent.com/u/7677641?v=3","gravatar_id":"","url":"https://api.github.com/users/danilms","html_url":"https://github.com/danilms","followers_url":"https://api.github.com/users/danilms/followers","following_url":"https://api.github.com/users/danilms/following{/other_user}","gists_url":"https://api.github.com/users/danilms/gists{/gist_id}","starred_url":"https://api.github.com/users/danilms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danilms/subscriptions","organizations_url":"https://api.github.com/users/danilms/orgs","repos_url":"https://api.github.com/users/danilms/repos","events_url":"https://api.github.com/users/danilms/events{/privacy}","received_events_url":"https://api.github.com/users/danilms/received_events","type":"User","site_admin":false},"repo":{"id":24883336,"name":"bookshelf","full_name":"danilms/bookshelf","owner":{"login":"danilms","id":7677641,"avatar_url":"https://avatars.githubusercontent.com/u/7677641?v=3","gravatar_id":"","url":"https://api.github.com/users/danilms","html_url":"https://github.com/danilms","followers_url":"https://api.github.com/users/danilms/followers","following_url":"https://api.github.com/users/danilms/following{/other_user}","gists_url":"https://api.github.com/users/danilms/gists{/gist_id}","starred_url":"https://api.github.com/users/danilms/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danilms/subscriptions","organizations_url":"https://api.github.com/users/danilms/orgs","repos_url":"https://api.github.com/users/danilms/repos","events_url":"https://api.github.com/users/danilms/events{/privacy}","received_events_url":"https://api.github.com/users/danilms/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/danilms/bookshelf","description":"Book storage for Opensoft","fork":true,"url":"https://api.github.com/repos/danilms/bookshelf","forks_url":"https://api.github.com/repos/danilms/bookshelf/forks","keys_url":"https://api.github.com/repos/danilms/bookshelf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/danilms/bookshelf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/danilms/bookshelf/teams","hooks_url":"https://api.github.com/repos/danilms/bookshelf/hooks","issue_events_url":"https://api.github.com/repos/danilms/bookshelf/issues/events{/number}","events_url":"https://api.github.com/repos/danilms/bookshelf/events","assignees_url":"https://api.github.com/repos/danilms/bookshelf/assignees{/user}","branches_url":"https://api.github.com/repos/danilms/bookshelf/branches{/branch}","tags_url":"https://api.github.com/repos/danilms/bookshelf/tags","blobs_url":"https://api.github.com/repos/danilms/bookshelf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/danilms/bookshelf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/danilms/bookshelf/git/refs{/sha}","trees_url":"https://api.github.com/repos/danilms/bookshelf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/danilms/bookshelf/statuses/{sha}","languages_url":"https://api.github.com/repos/danilms/bookshelf/languages","stargazers_url":"https://api.github.com/repos/danilms/bookshelf/stargazers","contributors_url":"https://api.github.com/repos/danilms/bookshelf/contributors","subscribers_url":"https://api.github.com/repos/danilms/bookshelf/subscribers","subscription_url":"https://api.github.com/repos/danilms/bookshelf/subscription","commits_url":"https://api.github.com/repos/danilms/bookshelf/commits{/sha}","git_commits_url":"https://api.github.com/repos/danilms/bookshelf/git/commits{/sha}","comments_url":"https://api.github.com/repos/danilms/bookshelf/comments{/number}","issue_comment_url":"https://api.github.com/repos/danilms/bookshelf/issues/comments/{number}","contents_url":"https://api.github.com/repos/danilms/bookshelf/contents/{+path}","compare_url":"https://api.github.com/repos/danilms/bookshelf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/danilms/bookshelf/merges","archive_url":"https://api.github.com/repos/danilms/bookshelf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/danilms/bookshelf/downloads","issues_url":"https://api.github.com/repos/danilms/bookshelf/issues{/number}","pulls_url":"https://api.github.com/repos/danilms/bookshelf/pulls{/number}","milestones_url":"https://api.github.com/repos/danilms/bookshelf/milestones{/number}","notifications_url":"https://api.github.com/repos/danilms/bookshelf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/danilms/bookshelf/labels{/name}","releases_url":"https://api.github.com/repos/danilms/bookshelf/releases{/id}","created_at":"2014-10-07T08:57:05Z","updated_at":"2014-10-28T09:24:50Z","pushed_at":"2014-11-12T13:31:43Z","git_url":"git://github.com/danilms/bookshelf.git","ssh_url":"git@github.com:danilms/bookshelf.git","clone_url":"https://github.com/danilms/bookshelf.git","svn_url":"https://github.com/danilms/bookshelf","homepage":null,"size":442,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bakulinav:master","ref":"master","sha":"18271bddd52ca0008cafb3eda3897d8a1a03bf0b","user":{"login":"bakulinav","id":341644,"avatar_url":"https://avatars.githubusercontent.com/u/341644?v=3","gravatar_id":"","url":"https://api.github.com/users/bakulinav","html_url":"https://github.com/bakulinav","followers_url":"https://api.github.com/users/bakulinav/followers","following_url":"https://api.github.com/users/bakulinav/following{/other_user}","gists_url":"https://api.github.com/users/bakulinav/gists{/gist_id}","starred_url":"https://api.github.com/users/bakulinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakulinav/subscriptions","organizations_url":"https://api.github.com/users/bakulinav/orgs","repos_url":"https://api.github.com/users/bakulinav/repos","events_url":"https://api.github.com/users/bakulinav/events{/privacy}","received_events_url":"https://api.github.com/users/bakulinav/received_events","type":"User","site_admin":false},"repo":{"id":24882220,"name":"bookshelf","full_name":"bakulinav/bookshelf","owner":{"login":"bakulinav","id":341644,"avatar_url":"https://avatars.githubusercontent.com/u/341644?v=3","gravatar_id":"","url":"https://api.github.com/users/bakulinav","html_url":"https://github.com/bakulinav","followers_url":"https://api.github.com/users/bakulinav/followers","following_url":"https://api.github.com/users/bakulinav/following{/other_user}","gists_url":"https://api.github.com/users/bakulinav/gists{/gist_id}","starred_url":"https://api.github.com/users/bakulinav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakulinav/subscriptions","organizations_url":"https://api.github.com/users/bakulinav/orgs","repos_url":"https://api.github.com/users/bakulinav/repos","events_url":"https://api.github.com/users/bakulinav/events{/privacy}","received_events_url":"https://api.github.com/users/bakulinav/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bakulinav/bookshelf","description":"Book storage for Opensoft","fork":false,"url":"https://api.github.com/repos/bakulinav/bookshelf","forks_url":"https://api.github.com/repos/bakulinav/bookshelf/forks","keys_url":"https://api.github.com/repos/bakulinav/bookshelf/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bakulinav/bookshelf/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bakulinav/bookshelf/teams","hooks_url":"https://api.github.com/repos/bakulinav/bookshelf/hooks","issue_events_url":"https://api.github.com/repos/bakulinav/bookshelf/issues/events{/number}","events_url":"https://api.github.com/repos/bakulinav/bookshelf/events","assignees_url":"https://api.github.com/repos/bakulinav/bookshelf/assignees{/user}","branches_url":"https://api.github.com/repos/bakulinav/bookshelf/branches{/branch}","tags_url":"https://api.github.com/repos/bakulinav/bookshelf/tags","blobs_url":"https://api.github.com/repos/bakulinav/bookshelf/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bakulinav/bookshelf/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bakulinav/bookshelf/git/refs{/sha}","trees_url":"https://api.github.com/repos/bakulinav/bookshelf/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bakulinav/bookshelf/statuses/{sha}","languages_url":"https://api.github.com/repos/bakulinav/bookshelf/languages","stargazers_url":"https://api.github.com/repos/bakulinav/bookshelf/stargazers","contributors_url":"https://api.github.com/repos/bakulinav/bookshelf/contributors","subscribers_url":"https://api.github.com/repos/bakulinav/bookshelf/subscribers","subscription_url":"https://api.github.com/repos/bakulinav/bookshelf/subscription","commits_url":"https://api.github.com/repos/bakulinav/bookshelf/commits{/sha}","git_commits_url":"https://api.github.com/repos/bakulinav/bookshelf/git/commits{/sha}","comments_url":"https://api.github.com/repos/bakulinav/bookshelf/comments{/number}","issue_comment_url":"https://api.github.com/repos/bakulinav/bookshelf/issues/comments/{number}","contents_url":"https://api.github.com/repos/bakulinav/bookshelf/contents/{+path}","compare_url":"https://api.github.com/repos/bakulinav/bookshelf/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bakulinav/bookshelf/merges","archive_url":"https://api.github.com/repos/bakulinav/bookshelf/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bakulinav/bookshelf/downloads","issues_url":"https://api.github.com/repos/bakulinav/bookshelf/issues{/number}","pulls_url":"https://api.github.com/repos/bakulinav/bookshelf/pulls{/number}","milestones_url":"https://api.github.com/repos/bakulinav/bookshelf/milestones{/number}","notifications_url":"https://api.github.com/repos/bakulinav/bookshelf/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bakulinav/bookshelf/labels{/name}","releases_url":"https://api.github.com/repos/bakulinav/bookshelf/releases{/id}","created_at":"2014-10-07T08:18:49Z","updated_at":"2014-10-10T11:59:10Z","pushed_at":"2014-11-12T16:24:09Z","git_url":"git://github.com/bakulinav/bookshelf.git","ssh_url":"git@github.com:bakulinav/bookshelf.git","clone_url":"https://github.com/bakulinav/bookshelf.git","svn_url":"https://github.com/bakulinav/bookshelf","homepage":null,"size":684,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24"},"html":{"href":"https://github.com/bakulinav/bookshelf/pull/24"},"issue":{"href":"https://api.github.com/repos/bakulinav/bookshelf/issues/24"},"comments":{"href":"https://api.github.com/repos/bakulinav/bookshelf/issues/24/comments"},"review_comments":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24/comments"},"review_comment":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/bakulinav/bookshelf/pulls/24/commits"},"statuses":{"href":"https://api.github.com/repos/bakulinav/bookshelf/statuses/a20bc6aa4b56be77b134bde5edbc2e0b4ee70506"}}}}