{"action":"created","comment":{"url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments/45983253","id":45983253,"diff_hunk":"@@ -0,0 +1,83 @@\n+<?php\n+\n+/**\n+ * Copyright 2015 SURFnet B.V.\n+ *\n+ * Licensed under the Apache License, Version 2.0 (the \"License\");\n+ * you may not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *     http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing, software\n+ * distributed under the License is distributed on an \"AS IS\" BASIS,\n+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+ * See the License for the specific language governing permissions and\n+ * limitations under the License.\n+ */\n+\n+namespace OpenConext\\ProfileBundle\\Service;\n+\n+use OpenConext\\Profile\\Value\\Consent;\n+use OpenConext\\Profile\\Value\\ConsentList;\n+use OpenConext\\ProfileBundle\\Exception\\RuntimeException;\n+use OpenConext\\ProfileBundle\\Security\\Authentication\\Entity\\User;\n+use OpenConext\\ProfileBundle\\User\\UserProvider;\n+use Surfnet\\SamlBundle\\SAML2\\Attribute\\Filter\\AttributeFilter;\n+\n+class ConsentListingService\n+{\n+    /**\n+     * @var UserProvider\n+     */\n+    private $userProvider;\n+\n+    /**\n+     * @var ConsentService\n+     */\n+    private $consentService;\n+\n+    /**\n+     * @var AttributeFilter\n+     */\n+    private $attributeFilter;\n+\n+    /**\n+     * @param UserProvider $userProvider\n+     * @param ConsentService $consentService\n+     * @param AttributeFilter $attributeFilter\n+     */\n+    public function __construct(\n+        UserProvider $userProvider,\n+        ConsentService $consentService,\n+        AttributeFilter $attributeFilter\n+    ) {\n+        $this->userProvider    = $userProvider;\n+        $this->consentService  = $consentService;\n+        $this->attributeFilter = $attributeFilter;\n+    }\n+\n+    /**\n+     * @return ConsentList\n+     */\n+    public function getConsentListing()\n+    {\n+        if (!$this->userProvider->hasCurrentUser()) {\n+            throw new RuntimeException('Cannot get consent listing: no current user available');\n+        }\n+\n+        $user               = $this->userProvider->getCurrentUser();\n+        $consentList        = $this->consentService->findAllFor($user);\n+        $filteredAttributes = $user->getAttributes()->apply($this->attributeFilter);\n+\n+        $newConsents = [];\n+\n+        /** @var Consent $consent */\n+        foreach ($consentList as $consent) {\n+            $newConsent = $consent->givenFor($filteredAttributes);\n+            $newConsents[] = $newConsent;","path":"src/OpenConext/ProfileBundle/Service/ConsentListingService.php","position":78,"original_position":78,"commit_id":"7bf9fb464141e4ed6bf3a5da6018fc0bc01d76ed","original_commit_id":"7bf9fb464141e4ed6bf3a5da6018fc0bc01d76ed","user":{"login":"rjkip","id":1734555,"avatar_url":"https://avatars.githubusercontent.com/u/1734555?v=3","gravatar_id":"","url":"https://api.github.com/users/rjkip","html_url":"https://github.com/rjkip","followers_url":"https://api.github.com/users/rjkip/followers","following_url":"https://api.github.com/users/rjkip/following{/other_user}","gists_url":"https://api.github.com/users/rjkip/gists{/gist_id}","starred_url":"https://api.github.com/users/rjkip/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjkip/subscriptions","organizations_url":"https://api.github.com/users/rjkip/orgs","repos_url":"https://api.github.com/users/rjkip/repos","events_url":"https://api.github.com/users/rjkip/events{/privacy}","received_events_url":"https://api.github.com/users/rjkip/received_events","type":"User","site_admin":false},"body":"Ah sorry, you start off with a ConsentList. Maybe a `ConsentList::map(callable $predicate):ConsentList` would be nice?","created_at":"2015-11-26T14:30:56Z","updated_at":"2015-11-26T14:30:56Z","html_url":"https://github.com/OpenConext/OpenConext-profile/pull/22#discussion_r45983253","pull_request_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments/45983253"},"html":{"href":"https://github.com/OpenConext/OpenConext-profile/pull/22#discussion_r45983253"},"pull_request":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22","id":51911183,"html_url":"https://github.com/OpenConext/OpenConext-profile/pull/22","diff_url":"https://github.com/OpenConext/OpenConext-profile/pull/22.diff","patch_url":"https://github.com/OpenConext/OpenConext-profile/pull/22.patch","issue_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/22","number":22,"state":"open","locked":false,"title":"Consent listing with filtered attributes","user":{"login":"arothuis","id":3816591,"avatar_url":"https://avatars.githubusercontent.com/u/3816591?v=3","gravatar_id":"","url":"https://api.github.com/users/arothuis","html_url":"https://github.com/arothuis","followers_url":"https://api.github.com/users/arothuis/followers","following_url":"https://api.github.com/users/arothuis/following{/other_user}","gists_url":"https://api.github.com/users/arothuis/gists{/gist_id}","starred_url":"https://api.github.com/users/arothuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arothuis/subscriptions","organizations_url":"https://api.github.com/users/arothuis/orgs","repos_url":"https://api.github.com/users/arothuis/repos","events_url":"https://api.github.com/users/arothuis/events{/privacy}","received_events_url":"https://api.github.com/users/arothuis/received_events","type":"User","site_admin":false},"body":"[Ticket 107811074](https://www.pivotaltracker.com/story/show/107811074)","created_at":"2015-11-26T13:15:53Z","updated_at":"2015-11-26T14:30:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"93760d9a80e63abdeae5c6819eac16d67c2bad47","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22/commits","review_comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22/comments","review_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/22/comments","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/7bf9fb464141e4ed6bf3a5da6018fc0bc01d76ed","head":{"label":"OpenConext:feature/filtered-attributes-in-consent-listing","ref":"feature/filtered-attributes-in-consent-listing","sha":"7bf9fb464141e4ed6bf3a5da6018fc0bc01d76ed","user":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"repo":{"id":44533794,"name":"OpenConext-profile","full_name":"OpenConext/OpenConext-profile","owner":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenConext/OpenConext-profile","description":"Shows user's attributes and other profile information","fork":false,"url":"https://api.github.com/repos/OpenConext/OpenConext-profile","forks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/forks","keys_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/teams","hooks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/hooks","issue_events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/events{/number}","events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/events","assignees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/assignees{/user}","branches_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/branches{/branch}","tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/tags","blobs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/languages","stargazers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/stargazers","contributors_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contributors","subscribers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscribers","subscription_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscription","commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contents/{+path}","compare_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/merges","archive_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/downloads","issues_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues{/number}","pulls_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/labels{/name}","releases_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/releases{/id}","created_at":"2015-10-19T12:42:43Z","updated_at":"2015-10-22T13:58:55Z","pushed_at":"2015-11-26T13:26:44Z","git_url":"git://github.com/OpenConext/OpenConext-profile.git","ssh_url":"git@github.com:OpenConext/OpenConext-profile.git","clone_url":"https://github.com/OpenConext/OpenConext-profile.git","svn_url":"https://github.com/OpenConext/OpenConext-profile","homepage":null,"size":2319,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"base":{"label":"OpenConext:develop","ref":"develop","sha":"97b70bed0f1a1dfa91fc4192cc32da1a026841c1","user":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"repo":{"id":44533794,"name":"OpenConext-profile","full_name":"OpenConext/OpenConext-profile","owner":{"login":"OpenConext","id":1457650,"avatar_url":"https://avatars.githubusercontent.com/u/1457650?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenConext","html_url":"https://github.com/OpenConext","followers_url":"https://api.github.com/users/OpenConext/followers","following_url":"https://api.github.com/users/OpenConext/following{/other_user}","gists_url":"https://api.github.com/users/OpenConext/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenConext/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenConext/subscriptions","organizations_url":"https://api.github.com/users/OpenConext/orgs","repos_url":"https://api.github.com/users/OpenConext/repos","events_url":"https://api.github.com/users/OpenConext/events{/privacy}","received_events_url":"https://api.github.com/users/OpenConext/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenConext/OpenConext-profile","description":"Shows user's attributes and other profile information","fork":false,"url":"https://api.github.com/repos/OpenConext/OpenConext-profile","forks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/forks","keys_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/teams","hooks_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/hooks","issue_events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/events{/number}","events_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/events","assignees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/assignees{/user}","branches_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/branches{/branch}","tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/tags","blobs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/languages","stargazers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/stargazers","contributors_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contributors","subscribers_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscribers","subscription_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/subscription","commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/contents/{+path}","compare_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/merges","archive_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/downloads","issues_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues{/number}","pulls_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/labels{/name}","releases_url":"https://api.github.com/repos/OpenConext/OpenConext-profile/releases{/id}","created_at":"2015-10-19T12:42:43Z","updated_at":"2015-10-22T13:58:55Z","pushed_at":"2015-11-26T13:26:44Z","git_url":"git://github.com/OpenConext/OpenConext-profile.git","ssh_url":"git@github.com:OpenConext/OpenConext-profile.git","clone_url":"https://github.com/OpenConext/OpenConext-profile.git","svn_url":"https://github.com/OpenConext/OpenConext-profile","homepage":null,"size":2319,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22"},"html":{"href":"https://github.com/OpenConext/OpenConext-profile/pull/22"},"issue":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/22"},"comments":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/OpenConext/OpenConext-profile/statuses/7bf9fb464141e4ed6bf3a5da6018fc0bc01d76ed"}}}}