{"action":"created","comment":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/comments/168528259","pull_request_review_id":96911173,"id":168528259,"diff_hunk":"@@ -0,0 +1,75 @@\n+<?php\n+\n+/*\n+ * This file is part of the Sonata Project package.\n+ *\n+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>\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 Sonata\\AdminBundle\\Twig\\Extension;\n+\n+use Sonata\\AdminBundle\\Admin\\AdminInterface;\n+use Sonata\\AdminBundle\\Admin\\Pool;\n+use Symfony\\Component\\HttpFoundation\\RequestStack;\n+use Twig\\Extension\\AbstractExtension;\n+use Twig\\TwigFunction;\n+\n+final class TemplateRegistryExtension extends AbstractExtension\n+{\n+    /**\n+     * @var Pool\n+     */\n+    private $pool;\n+\n+    /**\n+     * @var RequestStack\n+     */\n+    private $requestStack;\n+\n+    public function __construct(Pool $pool, RequestStack $requestStack)\n+    {\n+        $this->pool = $pool;\n+        $this->requestStack = $requestStack;\n+    }\n+\n+    public function getFunctions()\n+    {\n+        return [\n+            new TwigFunction('get_admin_template', [$this, 'getTemplate']),\n+            new TwigFunction('get_admin_pool_template', [$this, 'getPoolTemplate']),\n+        ];\n+    }\n+\n+    /**\n+     * @param string $name\n+     *\n+     * @return null|string\n+     */\n+    public function getTemplate($name)\n+    {\n+        return $this->getAdmin()->getTemplate($name);\n+    }\n+\n+    /**\n+     * @param string $name\n+     *\n+     * @return null|string\n+     */\n+    public function getPoolTemplate($name)\n+    {\n+        return $this->pool->getTemplate($name);\n+    }\n+\n+    /**\n+     * @return AdminInterface|false|null\n+     */\n+    private function getAdmin()\n+    {\n+        return $this->pool->getAdminByAdminCode(\n+            $this->requestStack->getCurrentRequest()->get('_sonata_admin')","path":"src/Twig/Extension/TemplateRegistryExtension.php","position":72,"original_position":72,"commit_id":"85ed866b7316f23a7bb229bfbbd40bb3c1cc14ff","original_commit_id":"85ed866b7316f23a7bb229bfbbd40bb3c1cc14ff","user":{"login":"TimoBakx","id":839801,"avatar_url":"https://avatars2.githubusercontent.com/u/839801?v=4","gravatar_id":"","url":"https://api.github.com/users/TimoBakx","html_url":"https://github.com/TimoBakx","followers_url":"https://api.github.com/users/TimoBakx/followers","following_url":"https://api.github.com/users/TimoBakx/following{/other_user}","gists_url":"https://api.github.com/users/TimoBakx/gists{/gist_id}","starred_url":"https://api.github.com/users/TimoBakx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimoBakx/subscriptions","organizations_url":"https://api.github.com/users/TimoBakx/orgs","repos_url":"https://api.github.com/users/TimoBakx/repos","events_url":"https://api.github.com/users/TimoBakx/events{/privacy}","received_events_url":"https://api.github.com/users/TimoBakx/received_events","type":"User","site_admin":false},"body":"Will do.","created_at":"2018-02-15T16:23:30Z","updated_at":"2018-02-15T16:23:30Z","html_url":"https://github.com/sonata-project/SonataAdminBundle/pull/4948#discussion_r168528259","pull_request_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/comments/168528259"},"html":{"href":"https://github.com/sonata-project/SonataAdminBundle/pull/4948#discussion_r168528259"},"pull_request":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948"}},"in_reply_to_id":168492634},"pull_request":{"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948","id":169364489,"html_url":"https://github.com/sonata-project/SonataAdminBundle/pull/4948","diff_url":"https://github.com/sonata-project/SonataAdminBundle/pull/4948.diff","patch_url":"https://github.com/sonata-project/SonataAdminBundle/pull/4948.patch","issue_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/4948","number":4948,"state":"open","locked":false,"title":"Moved Twig getTemplate calls to Twig extension","user":{"login":"TimoBakx","id":839801,"avatar_url":"https://avatars2.githubusercontent.com/u/839801?v=4","gravatar_id":"","url":"https://api.github.com/users/TimoBakx","html_url":"https://github.com/TimoBakx","followers_url":"https://api.github.com/users/TimoBakx/followers","following_url":"https://api.github.com/users/TimoBakx/following{/other_user}","gists_url":"https://api.github.com/users/TimoBakx/gists{/gist_id}","starred_url":"https://api.github.com/users/TimoBakx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimoBakx/subscriptions","organizations_url":"https://api.github.com/users/TimoBakx/orgs","repos_url":"https://api.github.com/users/TimoBakx/repos","events_url":"https://api.github.com/users/TimoBakx/events{/privacy}","received_events_url":"https://api.github.com/users/TimoBakx/received_events","type":"User","site_admin":false},"body":"I am targeting this branch, because it is BC.\r\n\r\n## Changelog\r\n\r\n```markdown\r\n### Added\r\n- Added Twig function `get_admin_template`\r\n- Added Twig function `get_admin_pool_template`\r\n\r\n### Changed\r\n- Changed calls to `admin.getTemplate()` in Twig templates to `get_admin_template()`\r\n- Changed calls to `adminPool.getTemplate()` in Twig templates to `get_admin_pool_template()`\r\n```\r\n\r\n## Subject\r\n\r\nThis PR is part of a series of PRs to eventually move all admin template related functions to a separate component.\r\n\r\nThis PR itself moves all direct calls to `AbstractAdmin::getTemplate()` and `Pool::getTemplate()` from Twig templates to a Twig extension.","created_at":"2018-02-15T12:58:12Z","updated_at":"2018-02-15T16:23:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"352f1f69b12bcec014ea1b3105efeffb1d01682f","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":371423923,"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/labels/Needs:%20Documentation","name":"Needs: Documentation","color":"006b75","default":false},{"id":371423924,"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/labels/Needs:%20Tests","name":"Needs: Tests","color":"006b75","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948/commits","review_comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948/comments","review_comment_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/4948/comments","statuses_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/statuses/85ed866b7316f23a7bb229bfbbd40bb3c1cc14ff","head":{"label":"TimoBakx:admin-gettemplate-twig-extension","ref":"admin-gettemplate-twig-extension","sha":"85ed866b7316f23a7bb229bfbbd40bb3c1cc14ff","user":{"login":"TimoBakx","id":839801,"avatar_url":"https://avatars2.githubusercontent.com/u/839801?v=4","gravatar_id":"","url":"https://api.github.com/users/TimoBakx","html_url":"https://github.com/TimoBakx","followers_url":"https://api.github.com/users/TimoBakx/followers","following_url":"https://api.github.com/users/TimoBakx/following{/other_user}","gists_url":"https://api.github.com/users/TimoBakx/gists{/gist_id}","starred_url":"https://api.github.com/users/TimoBakx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimoBakx/subscriptions","organizations_url":"https://api.github.com/users/TimoBakx/orgs","repos_url":"https://api.github.com/users/TimoBakx/repos","events_url":"https://api.github.com/users/TimoBakx/events{/privacy}","received_events_url":"https://api.github.com/users/TimoBakx/received_events","type":"User","site_admin":false},"repo":{"id":121227685,"name":"SonataAdminBundle","full_name":"TimoBakx/SonataAdminBundle","owner":{"login":"TimoBakx","id":839801,"avatar_url":"https://avatars2.githubusercontent.com/u/839801?v=4","gravatar_id":"","url":"https://api.github.com/users/TimoBakx","html_url":"https://github.com/TimoBakx","followers_url":"https://api.github.com/users/TimoBakx/followers","following_url":"https://api.github.com/users/TimoBakx/following{/other_user}","gists_url":"https://api.github.com/users/TimoBakx/gists{/gist_id}","starred_url":"https://api.github.com/users/TimoBakx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimoBakx/subscriptions","organizations_url":"https://api.github.com/users/TimoBakx/orgs","repos_url":"https://api.github.com/users/TimoBakx/repos","events_url":"https://api.github.com/users/TimoBakx/events{/privacy}","received_events_url":"https://api.github.com/users/TimoBakx/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/TimoBakx/SonataAdminBundle","description":"AdminBundle - The missing Symfony2 Admin Generator","fork":true,"url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle","forks_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/forks","keys_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/teams","hooks_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/hooks","issue_events_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/issues/events{/number}","events_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/events","assignees_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/assignees{/user}","branches_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/branches{/branch}","tags_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/tags","blobs_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/languages","stargazers_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/stargazers","contributors_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/contributors","subscribers_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/subscribers","subscription_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/subscription","commits_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/contents/{+path}","compare_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/merges","archive_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/downloads","issues_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/issues{/number}","pulls_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/labels{/name}","releases_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/releases{/id}","deployments_url":"https://api.github.com/repos/TimoBakx/SonataAdminBundle/deployments","created_at":"2018-02-12T09:41:23Z","updated_at":"2018-02-12T09:41:26Z","pushed_at":"2018-02-15T14:13:24Z","git_url":"git://github.com/TimoBakx/SonataAdminBundle.git","ssh_url":"git@github.com:TimoBakx/SonataAdminBundle.git","clone_url":"https://github.com/TimoBakx/SonataAdminBundle.git","svn_url":"https://github.com/TimoBakx/SonataAdminBundle","homepage":"https://sonata-project.org/","size":21017,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"3.x"}},"base":{"label":"sonata-project:3.x","ref":"3.x","sha":"c540777a466d7ae68372df0ec470d7b749c269cc","user":{"login":"sonata-project","id":404157,"avatar_url":"https://avatars0.githubusercontent.com/u/404157?v=4","gravatar_id":"","url":"https://api.github.com/users/sonata-project","html_url":"https://github.com/sonata-project","followers_url":"https://api.github.com/users/sonata-project/followers","following_url":"https://api.github.com/users/sonata-project/following{/other_user}","gists_url":"https://api.github.com/users/sonata-project/gists{/gist_id}","starred_url":"https://api.github.com/users/sonata-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonata-project/subscriptions","organizations_url":"https://api.github.com/users/sonata-project/orgs","repos_url":"https://api.github.com/users/sonata-project/repos","events_url":"https://api.github.com/users/sonata-project/events{/privacy}","received_events_url":"https://api.github.com/users/sonata-project/received_events","type":"Organization","site_admin":false},"repo":{"id":1095228,"name":"SonataAdminBundle","full_name":"sonata-project/SonataAdminBundle","owner":{"login":"sonata-project","id":404157,"avatar_url":"https://avatars0.githubusercontent.com/u/404157?v=4","gravatar_id":"","url":"https://api.github.com/users/sonata-project","html_url":"https://github.com/sonata-project","followers_url":"https://api.github.com/users/sonata-project/followers","following_url":"https://api.github.com/users/sonata-project/following{/other_user}","gists_url":"https://api.github.com/users/sonata-project/gists{/gist_id}","starred_url":"https://api.github.com/users/sonata-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sonata-project/subscriptions","organizations_url":"https://api.github.com/users/sonata-project/orgs","repos_url":"https://api.github.com/users/sonata-project/repos","events_url":"https://api.github.com/users/sonata-project/events{/privacy}","received_events_url":"https://api.github.com/users/sonata-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sonata-project/SonataAdminBundle","description":"AdminBundle - The missing Symfony2 Admin Generator","fork":false,"url":"https://api.github.com/repos/sonata-project/SonataAdminBundle","forks_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/forks","keys_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/teams","hooks_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/hooks","issue_events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/events{/number}","events_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/events","assignees_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/assignees{/user}","branches_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/branches{/branch}","tags_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/tags","blobs_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/languages","stargazers_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/stargazers","contributors_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/contributors","subscribers_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/subscribers","subscription_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/subscription","commits_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/contents/{+path}","compare_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/merges","archive_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/downloads","issues_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues{/number}","pulls_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/labels{/name}","releases_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/releases{/id}","deployments_url":"https://api.github.com/repos/sonata-project/SonataAdminBundle/deployments","created_at":"2010-11-19T17:08:52Z","updated_at":"2018-02-15T13:26:06Z","pushed_at":"2018-02-15T14:21:11Z","git_url":"git://github.com/sonata-project/SonataAdminBundle.git","ssh_url":"git@github.com:sonata-project/SonataAdminBundle.git","clone_url":"https://github.com/sonata-project/SonataAdminBundle.git","svn_url":"https://github.com/sonata-project/SonataAdminBundle","homepage":"https://sonata-project.org/","size":21002,"stargazers_count":1617,"watchers_count":1617,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1131,"mirror_url":null,"archived":false,"open_issues_count":324,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":1131,"open_issues":324,"watchers":1617,"default_branch":"3.x"}},"_links":{"self":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948"},"html":{"href":"https://github.com/sonata-project/SonataAdminBundle/pull/4948"},"issue":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/4948"},"comments":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/issues/4948/comments"},"review_comments":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948/comments"},"review_comment":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/pulls/4948/commits"},"statuses":{"href":"https://api.github.com/repos/sonata-project/SonataAdminBundle/statuses/85ed866b7316f23a7bb229bfbbd40bb3c1cc14ff"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"TimoBakx"}}