{"action":"created","comment":{"url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/comments/56767952","id":56767952,"diff_hunk":"@@ -0,0 +1,71 @@\n+<?php\n+\n+/**\n+ * @file\n+ * Contains \\Drupal\\custom_page\\Controller\\CustomPageController.\n+ */\n+\n+namespace Drupal\\custom_page\\Controller;\n+\n+use Drupal\\Core\\Access\\AccessResult;\n+use Drupal\\Core\\Controller\\ControllerBase;\n+use Drupal\\og\\Og;\n+use Drupal\\user\\Entity\\User;\n+\n+// @todo: Fix the description.\n+/**\n+ * Class CustomPageController.\n+ *\n+ * @package Drupal\\custom_page\\Controller\n+ */\n+class CustomPageController extends ControllerBase {\n+  // @todo: Fix the description.\n+  /**\n+   * Controller for the base form .\n+   *\n+   * @param \\Drupal\\rdf_entity\\RdfInterface $rdf_entity\n+   *   The collection rdf_entity.\n+   *\n+   * @return array\n+   *   Return the form array to be rendered.\n+   */\n+  public function add($rdf_entity) {\n+    // @todo: Find why value is not filtered.\n+    $node = $this->entityTypeManager()->getStorage('node')->create(array(\n+      'type' => 'custom_page',\n+      'og_group_ref' => $rdf_entity->Id()\n+    ));\n+\n+    // @todo: Change form name to include '_form' suffix.\n+    $form = $this->entityFormBuilder()->getForm($node, 'collection_custom_page');\n+\n+    return $form;\n+  }\n+\n+  /**\n+   * Handles accessibility to the custom page add form through collection pages.\n+   *\n+   * @return \\Drupal\\Core\\Access\\AccessResult\n+   *   The access result object.\n+   */\n+  public function access(){\n+    $rdf_entity = \\Drupal::routeMatch()->getParameter('rdf_entity');\n+    $account = \\Drupal::currentUser();\n+\n+    if($account->isAnonymous()){\n+      return AccessResult::forbidden();\n+    }\n+\n+    if($rdf_entity->bundle() != 'collection' ){\n+      return AccessResult::forbidden();\n+    }\n+\n+    // @todo: Fix the visibility to include og membership role dependency after ISAICP-2362.\n+    $user = User::load($account->id());\n+    if(!(Og::isMember($rdf_entity, $user))){\n+      return AccessResult::forbidden();\n+    }\n+\n+    return AccessResult::allowed();","path":"web/modules/custom/custom_page/src/Controller/CustomPageController.php","position":73,"original_position":69,"commit_id":"dcbc522533f086b171566f97e08e82dec99b8175","original_commit_id":"979c7b164baca7b1197801831e88a3afe13bbdcf","user":{"login":"idimopoulos","id":12171851,"avatar_url":"https://avatars.githubusercontent.com/u/12171851?v=3","gravatar_id":"","url":"https://api.github.com/users/idimopoulos","html_url":"https://github.com/idimopoulos","followers_url":"https://api.github.com/users/idimopoulos/followers","following_url":"https://api.github.com/users/idimopoulos/following{/other_user}","gists_url":"https://api.github.com/users/idimopoulos/gists{/gist_id}","starred_url":"https://api.github.com/users/idimopoulos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idimopoulos/subscriptions","organizations_url":"https://api.github.com/users/idimopoulos/orgs","repos_url":"https://api.github.com/users/idimopoulos/repos","events_url":"https://api.github.com/users/idimopoulos/events{/privacy}","received_events_url":"https://api.github.com/users/idimopoulos/received_events","type":"User","site_admin":false},"body":"I am not 100% sure but I think that allowed is the way to go here. The discussion on the 166 was about a field level access overriding the neutral access returned by all other handlers. \r\nAlso, node is returning a neutral access in order to be better integrated with the rest of the modules.\r\nBut in our case, we are overriding the default controller and form in order to alter it a bit and we provide our custom method to handle access through the route. In addition to that, we are not calling for any invocations nor are we part of any core flow since we overrode the access method. That makes this method the \"high bidder\". \r\nSo, considering that if all elements return a neutral access, then the access is denied, the high bidder is the one who should take the responsibility to allow the access.\r\n\r\nAlso, changing this to a neutral denies access to the page (because there is no method specifically allowing access and since no method explicitly cares for the access, the system does not care that much and denies it as it should) which backs up all the above a bit. :)","created_at":"2016-03-20T17:17:24Z","updated_at":"2016-03-20T17:17:24Z","html_url":"https://github.com/ec-europa/joinup-dev/pull/28#discussion_r56767952","pull_request_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28","_links":{"self":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/comments/56767952"},"html":{"href":"https://github.com/ec-europa/joinup-dev/pull/28#discussion_r56767952"},"pull_request":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28"}}},"pull_request":{"url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28","id":62991468,"html_url":"https://github.com/ec-europa/joinup-dev/pull/28","diff_url":"https://github.com/ec-europa/joinup-dev/pull/28.diff","patch_url":"https://github.com/ec-europa/joinup-dev/pull/28.patch","issue_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/28","number":28,"state":"open","locked":false,"title":"Isaicp 2237","user":{"login":"idimopoulos","id":12171851,"avatar_url":"https://avatars.githubusercontent.com/u/12171851?v=3","gravatar_id":"","url":"https://api.github.com/users/idimopoulos","html_url":"https://github.com/idimopoulos","followers_url":"https://api.github.com/users/idimopoulos/followers","following_url":"https://api.github.com/users/idimopoulos/following{/other_user}","gists_url":"https://api.github.com/users/idimopoulos/gists{/gist_id}","starred_url":"https://api.github.com/users/idimopoulos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idimopoulos/subscriptions","organizations_url":"https://api.github.com/users/idimopoulos/orgs","repos_url":"https://api.github.com/users/idimopoulos/repos","events_url":"https://api.github.com/users/idimopoulos/events{/privacy}","received_events_url":"https://api.github.com/users/idimopoulos/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-15T23:06:06Z","updated_at":"2016-03-20T17:17:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d57f7ded745bd7a2c282ebf8b6bdd61d28e05f2","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28/commits","review_comments_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28/comments","review_comment_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/28/comments","statuses_url":"https://api.github.com/repos/ec-europa/joinup-dev/statuses/dcbc522533f086b171566f97e08e82dec99b8175","head":{"label":"ec-europa:ISAICP-2237","ref":"ISAICP-2237","sha":"dcbc522533f086b171566f97e08e82dec99b8175","user":{"login":"ec-europa","id":10885565,"avatar_url":"https://avatars.githubusercontent.com/u/10885565?v=3","gravatar_id":"","url":"https://api.github.com/users/ec-europa","html_url":"https://github.com/ec-europa","followers_url":"https://api.github.com/users/ec-europa/followers","following_url":"https://api.github.com/users/ec-europa/following{/other_user}","gists_url":"https://api.github.com/users/ec-europa/gists{/gist_id}","starred_url":"https://api.github.com/users/ec-europa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ec-europa/subscriptions","organizations_url":"https://api.github.com/users/ec-europa/orgs","repos_url":"https://api.github.com/users/ec-europa/repos","events_url":"https://api.github.com/users/ec-europa/events{/privacy}","received_events_url":"https://api.github.com/users/ec-europa/received_events","type":"Organization","site_admin":false},"repo":{"id":46046597,"name":"joinup-dev","full_name":"ec-europa/joinup-dev","owner":{"login":"ec-europa","id":10885565,"avatar_url":"https://avatars.githubusercontent.com/u/10885565?v=3","gravatar_id":"","url":"https://api.github.com/users/ec-europa","html_url":"https://github.com/ec-europa","followers_url":"https://api.github.com/users/ec-europa/followers","following_url":"https://api.github.com/users/ec-europa/following{/other_user}","gists_url":"https://api.github.com/users/ec-europa/gists{/gist_id}","starred_url":"https://api.github.com/users/ec-europa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ec-europa/subscriptions","organizations_url":"https://api.github.com/users/ec-europa/orgs","repos_url":"https://api.github.com/users/ec-europa/repos","events_url":"https://api.github.com/users/ec-europa/events{/privacy}","received_events_url":"https://api.github.com/users/ec-europa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ec-europa/joinup-dev","description":"Joinup Drupal 8 development","fork":false,"url":"https://api.github.com/repos/ec-europa/joinup-dev","forks_url":"https://api.github.com/repos/ec-europa/joinup-dev/forks","keys_url":"https://api.github.com/repos/ec-europa/joinup-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ec-europa/joinup-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ec-europa/joinup-dev/teams","hooks_url":"https://api.github.com/repos/ec-europa/joinup-dev/hooks","issue_events_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/events{/number}","events_url":"https://api.github.com/repos/ec-europa/joinup-dev/events","assignees_url":"https://api.github.com/repos/ec-europa/joinup-dev/assignees{/user}","branches_url":"https://api.github.com/repos/ec-europa/joinup-dev/branches{/branch}","tags_url":"https://api.github.com/repos/ec-europa/joinup-dev/tags","blobs_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ec-europa/joinup-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/ec-europa/joinup-dev/languages","stargazers_url":"https://api.github.com/repos/ec-europa/joinup-dev/stargazers","contributors_url":"https://api.github.com/repos/ec-europa/joinup-dev/contributors","subscribers_url":"https://api.github.com/repos/ec-europa/joinup-dev/subscribers","subscription_url":"https://api.github.com/repos/ec-europa/joinup-dev/subscription","commits_url":"https://api.github.com/repos/ec-europa/joinup-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/ec-europa/joinup-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/ec-europa/joinup-dev/contents/{+path}","compare_url":"https://api.github.com/repos/ec-europa/joinup-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ec-europa/joinup-dev/merges","archive_url":"https://api.github.com/repos/ec-europa/joinup-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ec-europa/joinup-dev/downloads","issues_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues{/number}","pulls_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/ec-europa/joinup-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/ec-europa/joinup-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ec-europa/joinup-dev/labels{/name}","releases_url":"https://api.github.com/repos/ec-europa/joinup-dev/releases{/id}","deployments_url":"https://api.github.com/repos/ec-europa/joinup-dev/deployments","created_at":"2015-11-12T10:46:34Z","updated_at":"2016-02-12T14:02:35Z","pushed_at":"2016-03-20T17:00:28Z","git_url":"git://github.com/ec-europa/joinup-dev.git","ssh_url":"git@github.com:ec-europa/joinup-dev.git","clone_url":"https://github.com/ec-europa/joinup-dev.git","svn_url":"https://github.com/ec-europa/joinup-dev","homepage":null,"size":757,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"develop"}},"base":{"label":"ec-europa:develop","ref":"develop","sha":"ec00359548ce3501ebd073a8f908c831ea74e59f","user":{"login":"ec-europa","id":10885565,"avatar_url":"https://avatars.githubusercontent.com/u/10885565?v=3","gravatar_id":"","url":"https://api.github.com/users/ec-europa","html_url":"https://github.com/ec-europa","followers_url":"https://api.github.com/users/ec-europa/followers","following_url":"https://api.github.com/users/ec-europa/following{/other_user}","gists_url":"https://api.github.com/users/ec-europa/gists{/gist_id}","starred_url":"https://api.github.com/users/ec-europa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ec-europa/subscriptions","organizations_url":"https://api.github.com/users/ec-europa/orgs","repos_url":"https://api.github.com/users/ec-europa/repos","events_url":"https://api.github.com/users/ec-europa/events{/privacy}","received_events_url":"https://api.github.com/users/ec-europa/received_events","type":"Organization","site_admin":false},"repo":{"id":46046597,"name":"joinup-dev","full_name":"ec-europa/joinup-dev","owner":{"login":"ec-europa","id":10885565,"avatar_url":"https://avatars.githubusercontent.com/u/10885565?v=3","gravatar_id":"","url":"https://api.github.com/users/ec-europa","html_url":"https://github.com/ec-europa","followers_url":"https://api.github.com/users/ec-europa/followers","following_url":"https://api.github.com/users/ec-europa/following{/other_user}","gists_url":"https://api.github.com/users/ec-europa/gists{/gist_id}","starred_url":"https://api.github.com/users/ec-europa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ec-europa/subscriptions","organizations_url":"https://api.github.com/users/ec-europa/orgs","repos_url":"https://api.github.com/users/ec-europa/repos","events_url":"https://api.github.com/users/ec-europa/events{/privacy}","received_events_url":"https://api.github.com/users/ec-europa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ec-europa/joinup-dev","description":"Joinup Drupal 8 development","fork":false,"url":"https://api.github.com/repos/ec-europa/joinup-dev","forks_url":"https://api.github.com/repos/ec-europa/joinup-dev/forks","keys_url":"https://api.github.com/repos/ec-europa/joinup-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ec-europa/joinup-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ec-europa/joinup-dev/teams","hooks_url":"https://api.github.com/repos/ec-europa/joinup-dev/hooks","issue_events_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/events{/number}","events_url":"https://api.github.com/repos/ec-europa/joinup-dev/events","assignees_url":"https://api.github.com/repos/ec-europa/joinup-dev/assignees{/user}","branches_url":"https://api.github.com/repos/ec-europa/joinup-dev/branches{/branch}","tags_url":"https://api.github.com/repos/ec-europa/joinup-dev/tags","blobs_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ec-europa/joinup-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/ec-europa/joinup-dev/languages","stargazers_url":"https://api.github.com/repos/ec-europa/joinup-dev/stargazers","contributors_url":"https://api.github.com/repos/ec-europa/joinup-dev/contributors","subscribers_url":"https://api.github.com/repos/ec-europa/joinup-dev/subscribers","subscription_url":"https://api.github.com/repos/ec-europa/joinup-dev/subscription","commits_url":"https://api.github.com/repos/ec-europa/joinup-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/ec-europa/joinup-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/ec-europa/joinup-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/ec-europa/joinup-dev/contents/{+path}","compare_url":"https://api.github.com/repos/ec-europa/joinup-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ec-europa/joinup-dev/merges","archive_url":"https://api.github.com/repos/ec-europa/joinup-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ec-europa/joinup-dev/downloads","issues_url":"https://api.github.com/repos/ec-europa/joinup-dev/issues{/number}","pulls_url":"https://api.github.com/repos/ec-europa/joinup-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/ec-europa/joinup-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/ec-europa/joinup-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ec-europa/joinup-dev/labels{/name}","releases_url":"https://api.github.com/repos/ec-europa/joinup-dev/releases{/id}","deployments_url":"https://api.github.com/repos/ec-europa/joinup-dev/deployments","created_at":"2015-11-12T10:46:34Z","updated_at":"2016-02-12T14:02:35Z","pushed_at":"2016-03-20T17:00:28Z","git_url":"git://github.com/ec-europa/joinup-dev.git","ssh_url":"git@github.com:ec-europa/joinup-dev.git","clone_url":"https://github.com/ec-europa/joinup-dev.git","svn_url":"https://github.com/ec-europa/joinup-dev","homepage":null,"size":757,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":4,"forks":0,"open_issues":4,"watchers":1,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28"},"html":{"href":"https://github.com/ec-europa/joinup-dev/pull/28"},"issue":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/issues/28"},"comments":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/ec-europa/joinup-dev/statuses/dcbc522533f086b171566f97e08e82dec99b8175"}}}}