{"action":"created","comment":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/23944816","id":23944816,"diff_hunk":"@@ -0,0 +1,101 @@\n+<?php\n+\n+/*\n+ * This file is part of the Sylius package.\n+ *\n+ * (c) Paweł Jędrzejewski\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace Sylius\\Bundle\\ReportBundle\\Form\\EventListener;\n+\n+use Sylius\\Component\\Report\\Model\\ReportInterface;\n+use Sylius\\Component\\Registry\\ServiceRegistryInterface;\n+use Sylius\\Component\\Resource\\Exception\\UnexpectedTypeException;\n+use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n+use Symfony\\Component\\Form\\FormEvent;\n+use Symfony\\Component\\Form\\FormEvents;\n+use Symfony\\Component\\Form\\FormFactoryInterface;\n+use Symfony\\Component\\Form\\FormInterface;\n+\n+/**\n+ * This listener adds configuration form to the report object\n+ * if selected renderer requires one.\n+ *\n+ * @author Mateusz Zalewski <mateusz.zalewski@lakion.com>\n+ */\n+class BuildReportRendererFormListener implements EventSubscriberInterface\n+{\n+    /**\n+     * @var ServiceRegistryInterface\n+     */\n+    private $rendererRegistry;\n+\n+    /**\n+     * @var FormFactoryInterface\n+     */\n+    private $factory;\n+\n+    public function __construct(ServiceRegistryInterface $rendererRegistry, FormFactoryInterface $factory)\n+    {\n+        $this->rendererRegistry = $rendererRegistry;\n+        $this->factory = $factory;\n+    }\n+\n+    public static function getSubscribedEvents()\n+    {\n+        return array(\n+            FormEvents::PRE_SET_DATA => 'preSetData',\n+            FormEvents::PRE_SUBMIT   => 'preBind',\n+        );\n+    }\n+\n+    public function preSetData(FormEvent $event)\n+    {\n+        $report = $event->getData();\n+\n+        if (null === $report) {\n+            return;\n+        }\n+\n+        if (!$report instanceof ReportInterface) {\n+            throw new UnexpectedTypeException($report, 'Sylius\\Component\\Report\\Model\\ReportInterface');\n+        }\n+\n+        $this->addConfigurationFields($event->getForm(), $report->getRenderer(), $report->getRendererConfiguration());\n+    }\n+\n+    public function preBind(FormEvent $event)\n+    {\n+        $data = $event->getData();\n+\n+        if (empty($data) || !array_key_exists('renderer', $data)) {\n+            return;\n+        }\n+\n+        $this->addConfigurationFields($event->getForm(), $data['renderer']);\n+    }\n+\n+    /**\n+     * Add configuration fields to the form\n+     *\n+     * @param FormInterface $form\n+     * @param string        $rendererType\n+     * @param array         $data\n+     */\n+    public function addConfigurationFields(FormInterface $form, $rendererType, array $data = array())\n+    {\n+        $renderer = $this->rendererRegistry->get($rendererType);\n+        $formType = sprintf('sylius_renderer_%s', $renderer->getType());\n+\n+        try {\n+            $configurationField = $this->factory->createNamed('rendererConfiguration', $formType, $data, array('auto_initialize' => false));\n+        } catch (\\InvalidArgumentException $e) {\n+            var_dump($e);","path":"src/Sylius/Bundle/ReportBundle/Form/EventListener/BuildReportRendererFormListener.php","position":96,"original_position":96,"commit_id":"c9abe88903ad39a8e803c8270bb09bf62737a5b0","original_commit_id":"c9abe88903ad39a8e803c8270bb09bf62737a5b0","user":{"login":"stloyd","id":67402,"avatar_url":"https://avatars.githubusercontent.com/u/67402?v=3","gravatar_id":"","url":"https://api.github.com/users/stloyd","html_url":"https://github.com/stloyd","followers_url":"https://api.github.com/users/stloyd/followers","following_url":"https://api.github.com/users/stloyd/following{/other_user}","gists_url":"https://api.github.com/users/stloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/stloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stloyd/subscriptions","organizations_url":"https://api.github.com/users/stloyd/orgs","repos_url":"https://api.github.com/users/stloyd/repos","events_url":"https://api.github.com/users/stloyd/events{/privacy}","received_events_url":"https://api.github.com/users/stloyd/received_events","type":"User","site_admin":false},"body":"Really?","created_at":"2015-02-02T18:18:25Z","updated_at":"2015-02-02T18:18:25Z","html_url":"https://github.com/Sylius/Sylius/pull/2422#discussion_r23944816","pull_request_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2422","_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/23944816"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2422#discussion_r23944816"},"pull_request":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2422"}}},"pull_request":{"url":"https://api.github.com/repos/Sylius/Sylius/pulls/2422","id":28478781,"html_url":"https://github.com/Sylius/Sylius/pull/2422","diff_url":"https://github.com/Sylius/Sylius/pull/2422.diff","patch_url":"https://github.com/Sylius/Sylius/pull/2422.patch","issue_url":"https://api.github.com/repos/Sylius/Sylius/issues/2422","number":2422,"state":"open","locked":false,"title":"SyliusReportBundle","user":{"login":"Zales0123","id":6212718,"avatar_url":"https://avatars.githubusercontent.com/u/6212718?v=3","gravatar_id":"","url":"https://api.github.com/users/Zales0123","html_url":"https://github.com/Zales0123","followers_url":"https://api.github.com/users/Zales0123/followers","following_url":"https://api.github.com/users/Zales0123/following{/other_user}","gists_url":"https://api.github.com/users/Zales0123/gists{/gist_id}","starred_url":"https://api.github.com/users/Zales0123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zales0123/subscriptions","organizations_url":"https://api.github.com/users/Zales0123/orgs","repos_url":"https://api.github.com/users/Zales0123/repos","events_url":"https://api.github.com/users/Zales0123/events{/privacy}","received_events_url":"https://api.github.com/users/Zales0123/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes\r\n| BC breaks?    | no\r\n| Deprecations? | no\r\n| Fixed tickets | \r\n| License       | MIT\r\n| Doc PR        | https://github.com/Sylius/Sylius-Docs/pull/251\r\n\r\nSyliusReportBundle - flexible reports system, based on data fetchers and renderers. Now it's extremely easy to create a report with whatever data you want and nice look. Some default data fetchers and renderers already implemented, but adding another ones is a piece of cake. Find out more: https://github.com/Sylius/Sylius-Docs/pull/251\r\n![syliusreportbundle1](https://cloud.githubusercontent.com/assets/6212718/6003526/c0906e58-aafc-11e4-90f3-cfe0ba852ce7.jpg)\r\n![syliusreportbundle2](https://cloud.githubusercontent.com/assets/6212718/6003528/c321e160-aafc-11e4-9ea5-609fed9a9159.jpg)\r\n![syliusreportbundle3](https://cloud.githubusercontent.com/assets/6212718/6003530/c5bcfefa-aafc-11e4-9296-8aa90f980042.jpg)\r\n![syliusreportbundle4](https://cloud.githubusercontent.com/assets/6212718/6003531/c8779768-aafc-11e4-925a-c301d687ff07.jpg)\r\n\r\n\r\n\r\n","created_at":"2015-02-02T15:59:27Z","updated_at":"2015-02-02T18:18:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d88e1cca5dba4e2536377db9ed0e98deb5ad7494","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2422/commits","review_comments_url":"https://api.github.com/repos/Sylius/Sylius/pulls/2422/comments","review_comment_url":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}","comments_url":"https://api.github.com/repos/Sylius/Sylius/issues/2422/comments","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/c9abe88903ad39a8e803c8270bb09bf62737a5b0","head":{"label":"Zales0123:sylius-report-bundle","ref":"sylius-report-bundle","sha":"c9abe88903ad39a8e803c8270bb09bf62737a5b0","user":{"login":"Zales0123","id":6212718,"avatar_url":"https://avatars.githubusercontent.com/u/6212718?v=3","gravatar_id":"","url":"https://api.github.com/users/Zales0123","html_url":"https://github.com/Zales0123","followers_url":"https://api.github.com/users/Zales0123/followers","following_url":"https://api.github.com/users/Zales0123/following{/other_user}","gists_url":"https://api.github.com/users/Zales0123/gists{/gist_id}","starred_url":"https://api.github.com/users/Zales0123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zales0123/subscriptions","organizations_url":"https://api.github.com/users/Zales0123/orgs","repos_url":"https://api.github.com/users/Zales0123/repos","events_url":"https://api.github.com/users/Zales0123/events{/privacy}","received_events_url":"https://api.github.com/users/Zales0123/received_events","type":"User","site_admin":false},"repo":{"id":28911466,"name":"Sylius","full_name":"Zales0123/Sylius","owner":{"login":"Zales0123","id":6212718,"avatar_url":"https://avatars.githubusercontent.com/u/6212718?v=3","gravatar_id":"","url":"https://api.github.com/users/Zales0123","html_url":"https://github.com/Zales0123","followers_url":"https://api.github.com/users/Zales0123/followers","following_url":"https://api.github.com/users/Zales0123/following{/other_user}","gists_url":"https://api.github.com/users/Zales0123/gists{/gist_id}","starred_url":"https://api.github.com/users/Zales0123/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Zales0123/subscriptions","organizations_url":"https://api.github.com/users/Zales0123/orgs","repos_url":"https://api.github.com/users/Zales0123/repos","events_url":"https://api.github.com/users/Zales0123/events{/privacy}","received_events_url":"https://api.github.com/users/Zales0123/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Zales0123/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":true,"url":"https://api.github.com/repos/Zales0123/Sylius","forks_url":"https://api.github.com/repos/Zales0123/Sylius/forks","keys_url":"https://api.github.com/repos/Zales0123/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Zales0123/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Zales0123/Sylius/teams","hooks_url":"https://api.github.com/repos/Zales0123/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Zales0123/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Zales0123/Sylius/events","assignees_url":"https://api.github.com/repos/Zales0123/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Zales0123/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Zales0123/Sylius/tags","blobs_url":"https://api.github.com/repos/Zales0123/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Zales0123/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Zales0123/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Zales0123/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Zales0123/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Zales0123/Sylius/languages","stargazers_url":"https://api.github.com/repos/Zales0123/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Zales0123/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Zales0123/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Zales0123/Sylius/subscription","commits_url":"https://api.github.com/repos/Zales0123/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Zales0123/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Zales0123/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Zales0123/Sylius/issues/comments/{number}","contents_url":"https://api.github.com/repos/Zales0123/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Zales0123/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Zales0123/Sylius/merges","archive_url":"https://api.github.com/repos/Zales0123/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Zales0123/Sylius/downloads","issues_url":"https://api.github.com/repos/Zales0123/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Zales0123/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Zales0123/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Zales0123/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Zales0123/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Zales0123/Sylius/releases{/id}","created_at":"2015-01-07T11:20:44Z","updated_at":"2015-01-07T11:20:51Z","pushed_at":"2015-02-02T15:51:34Z","git_url":"git://github.com/Zales0123/Sylius.git","ssh_url":"git@github.com:Zales0123/Sylius.git","clone_url":"https://github.com/Zales0123/Sylius.git","svn_url":"https://github.com/Zales0123/Sylius","homepage":"Sylius.org","size":15816,"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":"Sylius:master","ref":"master","sha":"0d015923436bfc9e540aaaaaaaed08d86ff6430a","user":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"repo":{"id":2717549,"name":"Sylius","full_name":"Sylius/Sylius","owner":{"login":"Sylius","id":719423,"avatar_url":"https://avatars.githubusercontent.com/u/719423?v=3","gravatar_id":"","url":"https://api.github.com/users/Sylius","html_url":"https://github.com/Sylius","followers_url":"https://api.github.com/users/Sylius/followers","following_url":"https://api.github.com/users/Sylius/following{/other_user}","gists_url":"https://api.github.com/users/Sylius/gists{/gist_id}","starred_url":"https://api.github.com/users/Sylius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sylius/subscriptions","organizations_url":"https://api.github.com/users/Sylius/orgs","repos_url":"https://api.github.com/users/Sylius/repos","events_url":"https://api.github.com/users/Sylius/events{/privacy}","received_events_url":"https://api.github.com/users/Sylius/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Sylius/Sylius","description":"Modern e-commerce for PHP, based on the Symfony2 framework.","fork":false,"url":"https://api.github.com/repos/Sylius/Sylius","forks_url":"https://api.github.com/repos/Sylius/Sylius/forks","keys_url":"https://api.github.com/repos/Sylius/Sylius/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Sylius/Sylius/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Sylius/Sylius/teams","hooks_url":"https://api.github.com/repos/Sylius/Sylius/hooks","issue_events_url":"https://api.github.com/repos/Sylius/Sylius/issues/events{/number}","events_url":"https://api.github.com/repos/Sylius/Sylius/events","assignees_url":"https://api.github.com/repos/Sylius/Sylius/assignees{/user}","branches_url":"https://api.github.com/repos/Sylius/Sylius/branches{/branch}","tags_url":"https://api.github.com/repos/Sylius/Sylius/tags","blobs_url":"https://api.github.com/repos/Sylius/Sylius/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Sylius/Sylius/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Sylius/Sylius/git/refs{/sha}","trees_url":"https://api.github.com/repos/Sylius/Sylius/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Sylius/Sylius/statuses/{sha}","languages_url":"https://api.github.com/repos/Sylius/Sylius/languages","stargazers_url":"https://api.github.com/repos/Sylius/Sylius/stargazers","contributors_url":"https://api.github.com/repos/Sylius/Sylius/contributors","subscribers_url":"https://api.github.com/repos/Sylius/Sylius/subscribers","subscription_url":"https://api.github.com/repos/Sylius/Sylius/subscription","commits_url":"https://api.github.com/repos/Sylius/Sylius/commits{/sha}","git_commits_url":"https://api.github.com/repos/Sylius/Sylius/git/commits{/sha}","comments_url":"https://api.github.com/repos/Sylius/Sylius/comments{/number}","issue_comment_url":"https://api.github.com/repos/Sylius/Sylius/issues/comments/{number}","contents_url":"https://api.github.com/repos/Sylius/Sylius/contents/{+path}","compare_url":"https://api.github.com/repos/Sylius/Sylius/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Sylius/Sylius/merges","archive_url":"https://api.github.com/repos/Sylius/Sylius/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Sylius/Sylius/downloads","issues_url":"https://api.github.com/repos/Sylius/Sylius/issues{/number}","pulls_url":"https://api.github.com/repos/Sylius/Sylius/pulls{/number}","milestones_url":"https://api.github.com/repos/Sylius/Sylius/milestones{/number}","notifications_url":"https://api.github.com/repos/Sylius/Sylius/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Sylius/Sylius/labels{/name}","releases_url":"https://api.github.com/repos/Sylius/Sylius/releases{/id}","created_at":"2011-11-05T22:05:52Z","updated_at":"2015-02-02T15:28:35Z","pushed_at":"2015-02-02T14:19:26Z","git_url":"git://github.com/Sylius/Sylius.git","ssh_url":"git@github.com:Sylius/Sylius.git","clone_url":"https://github.com/Sylius/Sylius.git","svn_url":"https://github.com/Sylius/Sylius","homepage":"Sylius.org","size":41095,"stargazers_count":1577,"watchers_count":1577,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":531,"mirror_url":null,"open_issues_count":383,"forks":531,"open_issues":383,"watchers":1577,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2422"},"html":{"href":"https://github.com/Sylius/Sylius/pull/2422"},"issue":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2422"},"comments":{"href":"https://api.github.com/repos/Sylius/Sylius/issues/2422/comments"},"review_comments":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2422/comments"},"review_comment":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/Sylius/Sylius/pulls/2422/commits"},"statuses":{"href":"https://api.github.com/repos/Sylius/Sylius/statuses/c9abe88903ad39a8e803c8270bb09bf62737a5b0"}}}}