{"action":"created","comment":{"url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/comments/26322762","id":26322762,"diff_hunk":"@@ -0,0 +1,106 @@\n+<?php\n+/**\n+ * File containing the RecommendationController class.\n+ *\n+ * @copyright Copyright (C) eZ Systems AS. All rights reserved.\n+ * @license For full copyright and license information view LICENSE file distributed with this source code.\n+ * @version //autogentag//\n+ */\n+\n+namespace EzSystems\\RecommendationBundle\\Controller;\n+\n+use eZ\\Bundle\\EzPublishCoreBundle\\Controller;\n+use Symfony\\Component\\HttpFoundation\\JsonResponse;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+use EzSystems\\RecommendationBundle\\Client\\YooChooseNotifier;\n+use eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\Criterion;\n+use eZ\\Publish\\API\\Repository\\Values\\Content\\LocationQuery;\n+use eZ\\Publish\\API\\Repository\\Values\\Content\\Query;\n+use eZ\\Publish\\API\\Repository\\Values\\Content\\Query\\SortClause;\n+\n+class RecommendationController extends Controller\n+{\n+    public function recommendationsAction( Request $request )\n+    {\n+        if ( !$request->isXmlHttpRequest() ) {\n+            throw new BadRequestHttpException();\n+        }\n+\n+        $userId = $this->getRepository()->getCurrentUser()->id;\n+        $locationId = $request->query->get( 'locationId' );\n+        $limit = $request->query->get( 'limit' );\n+        $scenarioId = $request->query->get( 'scenarioId' );\n+\n+        $notifier = $this->get( 'ez_recommendation.client.yoochoose_notifier' );\n+\n+        $responseRecommendations = $notifier->getRecommendations(\n+            $userId, $scenarioId, $locationId, $limit\n+        );\n+\n+        $recommendedContentIds = array();\n+\n+        foreach ( $responseRecommendations[ 'recommendationResponseList' ] as $recommendation ) {\n+            $recommendedContentIds[] = $recommendation[ 'itemId' ];\n+        }\n+\n+        $content = array();\n+\n+        if ( count( $recommendedContentIds ) > 0 ) {\n+\n+            $criterion = new Criterion\\LogicalAnd( array(\n+                new Criterion\\Visibility( Criterion\\Visibility::VISIBLE ),\n+                new Criterion\\ContentId( $recommendedContentIds ),\n+                new Criterion\\ContentTypeIdentifier( array( 'article', 'blog_post' ) )\n+            ));\n+\n+            $contentQuery = new LocationQuery();\n+            $contentQuery->criterion = $criterion;\n+            $contentQuery->sortClauses = array(\n+                new SortClause\\ContentName()\n+            );\n+\n+            $searchService = $this->getRepository()->getSearchService();\n+            $searchResults = $searchService->findLocations( $contentQuery );\n+\n+            $language = $this->getRepository()->getContentLanguageService()->getDefaultLanguageCode();\n+\n+            foreach ($searchResults->searchHits as $result) {\n+                $contentData = $this->getRepository()->getContentService()->loadContentByContentInfo( $result->valueObject->contentInfo );\n+\n+                // get content name","path":"Controller/RecommendationController.php","position":70,"original_position":70,"commit_id":"946607e78cb9bfa11c60654cdf4b6fc66bd643a4","original_commit_id":"946607e78cb9bfa11c60654cdf4b6fc66bd643a4","user":{"login":"bdunogier","id":235928,"avatar_url":"https://avatars.githubusercontent.com/u/235928?v=3","gravatar_id":"","url":"https://api.github.com/users/bdunogier","html_url":"https://github.com/bdunogier","followers_url":"https://api.github.com/users/bdunogier/followers","following_url":"https://api.github.com/users/bdunogier/following{/other_user}","gists_url":"https://api.github.com/users/bdunogier/gists{/gist_id}","starred_url":"https://api.github.com/users/bdunogier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdunogier/subscriptions","organizations_url":"https://api.github.com/users/bdunogier/orgs","repos_url":"https://api.github.com/users/bdunogier/repos","events_url":"https://api.github.com/users/bdunogier/events{/privacy}","received_events_url":"https://api.github.com/users/bdunogier/received_events","type":"User","site_admin":false},"body":"I don't thin you need those comments. \"$result->valueObject->contentInfo->name;\" doesn't leave much place to doubt when reading it, does it ? :-)\r\n\r\nThe same goes for all the lines below.","created_at":"2015-03-12T17:12:52Z","updated_at":"2015-03-12T17:12:52Z","html_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10#discussion_r26322762","pull_request_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10","_links":{"self":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/comments/26322762"},"html":{"href":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10#discussion_r26322762"},"pull_request":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10"}}},"pull_request":{"url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10","id":31025638,"html_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10","diff_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10.diff","patch_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10.patch","issue_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/10","number":10,"state":"open","locked":false,"title":"EZP-24016: Prototype RecommendationBundle integration with DemoBundle","user":{"login":"clash82","id":3033038,"avatar_url":"https://avatars.githubusercontent.com/u/3033038?v=3","gravatar_id":"","url":"https://api.github.com/users/clash82","html_url":"https://github.com/clash82","followers_url":"https://api.github.com/users/clash82/followers","following_url":"https://api.github.com/users/clash82/following{/other_user}","gists_url":"https://api.github.com/users/clash82/gists{/gist_id}","starred_url":"https://api.github.com/users/clash82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clash82/subscriptions","organizations_url":"https://api.github.com/users/clash82/orgs","repos_url":"https://api.github.com/users/clash82/repos","events_url":"https://api.github.com/users/clash82/events{/privacy}","received_events_url":"https://api.github.com/users/clash82/received_events","type":"User","site_admin":false},"body":"Link to Jira task: https://jira.ez.no/browse/EZP-24016\r\n\r\nNote: instructions on how to use it on DemoBundle will be added later.","created_at":"2015-03-12T11:02:38Z","updated_at":"2015-03-12T17:12:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"52d33066e15b6c8c2e6661476d1d163c7767f685","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10/commits","review_comments_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10/comments","review_comment_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/10/comments","statuses_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/statuses/946607e78cb9bfa11c60654cdf4b6fc66bd643a4","head":{"label":"clash82:demoreco","ref":"demoreco","sha":"946607e78cb9bfa11c60654cdf4b6fc66bd643a4","user":{"login":"clash82","id":3033038,"avatar_url":"https://avatars.githubusercontent.com/u/3033038?v=3","gravatar_id":"","url":"https://api.github.com/users/clash82","html_url":"https://github.com/clash82","followers_url":"https://api.github.com/users/clash82/followers","following_url":"https://api.github.com/users/clash82/following{/other_user}","gists_url":"https://api.github.com/users/clash82/gists{/gist_id}","starred_url":"https://api.github.com/users/clash82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clash82/subscriptions","organizations_url":"https://api.github.com/users/clash82/orgs","repos_url":"https://api.github.com/users/clash82/repos","events_url":"https://api.github.com/users/clash82/events{/privacy}","received_events_url":"https://api.github.com/users/clash82/received_events","type":"User","site_admin":false},"repo":{"id":31544283,"name":"EzSystemsRecommendationBundle","full_name":"clash82/EzSystemsRecommendationBundle","owner":{"login":"clash82","id":3033038,"avatar_url":"https://avatars.githubusercontent.com/u/3033038?v=3","gravatar_id":"","url":"https://api.github.com/users/clash82","html_url":"https://github.com/clash82","followers_url":"https://api.github.com/users/clash82/followers","following_url":"https://api.github.com/users/clash82/following{/other_user}","gists_url":"https://api.github.com/users/clash82/gists{/gist_id}","starred_url":"https://api.github.com/users/clash82/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clash82/subscriptions","organizations_url":"https://api.github.com/users/clash82/orgs","repos_url":"https://api.github.com/users/clash82/repos","events_url":"https://api.github.com/users/clash82/events{/privacy}","received_events_url":"https://api.github.com/users/clash82/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/clash82/EzSystemsRecommendationBundle","description":"Integration of YooChoose, a content recommendation solution, into eZ Platform","fork":true,"url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle","forks_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/forks","keys_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/teams","hooks_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/hooks","issue_events_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/issues/events{/number}","events_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/events","assignees_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/assignees{/user}","branches_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/branches{/branch}","tags_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/tags","blobs_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/languages","stargazers_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/stargazers","contributors_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/contributors","subscribers_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/subscribers","subscription_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/subscription","commits_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/contents/{+path}","compare_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/merges","archive_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/downloads","issues_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/issues{/number}","pulls_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/labels{/name}","releases_url":"https://api.github.com/repos/clash82/EzSystemsRecommendationBundle/releases{/id}","created_at":"2015-03-02T14:33:04Z","updated_at":"2015-03-02T14:33:04Z","pushed_at":"2015-03-12T14:13:03Z","git_url":"git://github.com/clash82/EzSystemsRecommendationBundle.git","ssh_url":"git@github.com:clash82/EzSystemsRecommendationBundle.git","clone_url":"https://github.com/clash82/EzSystemsRecommendationBundle.git","svn_url":"https://github.com/clash82/EzSystemsRecommendationBundle","homepage":null,"size":127,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"ezsystems:master","ref":"master","sha":"566cbc2b8b2720dd29dc54135eee1ba13e5e5459","user":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"repo":{"id":27641523,"name":"EzSystemsRecommendationBundle","full_name":"ezsystems/EzSystemsRecommendationBundle","owner":{"login":"ezsystems","id":295311,"avatar_url":"https://avatars.githubusercontent.com/u/295311?v=3","gravatar_id":"","url":"https://api.github.com/users/ezsystems","html_url":"https://github.com/ezsystems","followers_url":"https://api.github.com/users/ezsystems/followers","following_url":"https://api.github.com/users/ezsystems/following{/other_user}","gists_url":"https://api.github.com/users/ezsystems/gists{/gist_id}","starred_url":"https://api.github.com/users/ezsystems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ezsystems/subscriptions","organizations_url":"https://api.github.com/users/ezsystems/orgs","repos_url":"https://api.github.com/users/ezsystems/repos","events_url":"https://api.github.com/users/ezsystems/events{/privacy}","received_events_url":"https://api.github.com/users/ezsystems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle","description":"Integration of YooChoose, a content recommendation solution, into eZ Platform","fork":false,"url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle","forks_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/forks","keys_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/teams","hooks_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/hooks","issue_events_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/events{/number}","events_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/events","assignees_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/assignees{/user}","branches_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/branches{/branch}","tags_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/tags","blobs_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/languages","stargazers_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/stargazers","contributors_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/contributors","subscribers_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/subscribers","subscription_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/subscription","commits_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/contents/{+path}","compare_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/merges","archive_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/downloads","issues_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues{/number}","pulls_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/labels{/name}","releases_url":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/releases{/id}","created_at":"2014-12-06T16:56:48Z","updated_at":"2015-01-30T10:41:52Z","pushed_at":"2015-01-30T10:41:52Z","git_url":"git://github.com/ezsystems/EzSystemsRecommendationBundle.git","ssh_url":"git@github.com:ezsystems/EzSystemsRecommendationBundle.git","clone_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle.git","svn_url":"https://github.com/ezsystems/EzSystemsRecommendationBundle","homepage":null,"size":442,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10"},"html":{"href":"https://github.com/ezsystems/EzSystemsRecommendationBundle/pull/10"},"issue":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/10"},"comments":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/ezsystems/EzSystemsRecommendationBundle/statuses/946607e78cb9bfa11c60654cdf4b6fc66bd643a4"}}}}