{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/27776697","id":27776697,"diff_hunk":"@@ -0,0 +1,46 @@\n+<?php\n+\n+/*\n+ * This file is part of the Symfony package.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\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 Symfony\\Component\\Config;\n+\n+/**\n+ * Default implementation for ConfigCacheFactoryInterface\n+ * that will create an instance of ConfigCache.\n+ *\n+ * @author Matthias Pigulla <mp@webfactory.de>\n+ */\n+class DefaultConfigCacheFactory implements ConfigCacheFactoryInterface\n+{\n+    /** @var bool Debug flag passed to the ConfigCache */\n+    private $debug;\n+\n+    /**\n+     * @param bool $debug The debug flag to pass to ConfigCache\n+     */\n+    public function __construct($debug)\n+    {\n+        $this->debug = $debug;\n+    }\n+\n+    /**\n+     * {@inheritdoc}\n+     */\n+    public function cache($file, $callback)\n+    {\n+        $cache = new ConfigCache($file, $this->debug);","path":"src/Symfony/Component/Config/DefaultConfigCacheFactory.php","position":38,"original_position":38,"commit_id":"e3ac659a136269ae4f78aa2f1a978d7cd597b88d","original_commit_id":"e3ac659a136269ae4f78aa2f1a978d7cd597b88d","user":{"login":"iltar","id":1754678,"avatar_url":"https://avatars.githubusercontent.com/u/1754678?v=3","gravatar_id":"","url":"https://api.github.com/users/iltar","html_url":"https://github.com/iltar","followers_url":"https://api.github.com/users/iltar/followers","following_url":"https://api.github.com/users/iltar/following{/other_user}","gists_url":"https://api.github.com/users/iltar/gists{/gist_id}","starred_url":"https://api.github.com/users/iltar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iltar/subscriptions","organizations_url":"https://api.github.com/users/iltar/orgs","repos_url":"https://api.github.com/users/iltar/repos","events_url":"https://api.github.com/users/iltar/events{/privacy}","received_events_url":"https://api.github.com/users/iltar/received_events","type":"User","site_admin":false},"body":"This comment will probably fall a bit out of scope, but I'd like to comment it either way. \r\n\r\nThe `$debug` value is as far as I can see, only used to force a rebuild in dev: [ConfigCache.php#L67-L69](https://github.com/symfony/symfony/blob/eee117285ae84b9aa859814d6d0cef9fd7f05baa/src/Symfony/Component/Config/ConfigCache.php#L67-L69). In my opinion, the code should be as little aware of the dev/prod/debug as possible. \r\n\r\nHowever, now that there is a factory, this can easily be solved; In debug the set method injecting the factory could actually inject an instance of a `DebugConfigCacheFactory`, which by default generates a `DebugCacheConfig` and just returns `true` on `isFresh()`. That means you most likely won't have to bother with the `debug` value through the code, which simplifies a lot and keeps debug code separated from the normal flow.","created_at":"2015-04-05T11:55:30Z","updated_at":"2015-04-05T11:55:30Z","html_url":"https://github.com/symfony/symfony/pull/14178#discussion_r27776697","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/14178","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/27776697"},"html":{"href":"https://github.com/symfony/symfony/pull/14178#discussion_r27776697"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14178"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/14178","id":32511774,"html_url":"https://github.com/symfony/symfony/pull/14178","diff_url":"https://github.com/symfony/symfony/pull/14178.diff","patch_url":"https://github.com/symfony/symfony/pull/14178.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14178","number":14178,"state":"open","locked":false,"title":"[Config] Delegate creation of ConfigCache instances to a factory.","user":{"login":"mpdude","id":1202333,"avatar_url":"https://avatars.githubusercontent.com/u/1202333?v=3","gravatar_id":"","url":"https://api.github.com/users/mpdude","html_url":"https://github.com/mpdude","followers_url":"https://api.github.com/users/mpdude/followers","following_url":"https://api.github.com/users/mpdude/following{/other_user}","gists_url":"https://api.github.com/users/mpdude/gists{/gist_id}","starred_url":"https://api.github.com/users/mpdude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpdude/subscriptions","organizations_url":"https://api.github.com/users/mpdude/orgs","repos_url":"https://api.github.com/users/mpdude/repos","events_url":"https://api.github.com/users/mpdude/events{/privacy}","received_events_url":"https://api.github.com/users/mpdude/received_events","type":"User","site_admin":false},"body":"| Q             | A\r\n| ------------- | ---\r\n| Bug fix?      | no\r\n| New feature?  | yes (refactoring, new flex point)\r\n| BC breaks?    | no\r\n| Deprecations? | yes\r\n| Tests pass?   | we'll see :-)\r\n| Fixed tickets | n/a\r\n| License       | MIT\r\n| Doc PR        | symfony/symfony-docs#5136\r\n\r\nIn the Routing/Router and Translation/Translator, delegate creation of ConfigCache instances to a factory. The factory can be setter-injected but will default to a BC implementation.\r\n\r\nThe ```ConfigCacheFactoryInterface``` is designed in a way that captures the common ```$cache = new ...; if (!$cache->isFresh()) { ... do sth }``` pattern. But more importantly, this design allows factory implementations to take additional measures to avoid race conditions before actually filling the cache.\r\n\r\nBy using an exchangeable ConfigCache factory it becomes possible to implement different resource (freshness) checking strategies, especially service-based ones. \r\n\r\nThe goal is to be able to validate Translators and Routers generated by database-based loaders. It might also help with symfony/AsseticBundle#168. This PR only contains the minimum changes needed, so the rest could be implemented in a bundle outside the core (at least for the beginning).\r\n\r\nComponent/HttpKernel/Kernel::initializeContainer still uses the ConfigCache implementation directly as there is no sensible way of getting/injecting a factory service (chicken-egg).\r\n\r\nThis is a pick off #7230. It replaces #7781 which was against the master branch. Also see #7781 for additional comments/explanations.","created_at":"2015-04-02T13:37:00Z","updated_at":"2015-04-05T11:55:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a52f360f1d6dbf54a15504ecd31c071fc41a8af0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/14178/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/14178/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14178/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/e3ac659a136269ae4f78aa2f1a978d7cd597b88d","head":{"label":"webfactory:7781-on-2.7","ref":"7781-on-2.7","sha":"e3ac659a136269ae4f78aa2f1a978d7cd597b88d","user":{"login":"webfactory","id":135788,"avatar_url":"https://avatars.githubusercontent.com/u/135788?v=3","gravatar_id":"","url":"https://api.github.com/users/webfactory","html_url":"https://github.com/webfactory","followers_url":"https://api.github.com/users/webfactory/followers","following_url":"https://api.github.com/users/webfactory/following{/other_user}","gists_url":"https://api.github.com/users/webfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/webfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webfactory/subscriptions","organizations_url":"https://api.github.com/users/webfactory/orgs","repos_url":"https://api.github.com/users/webfactory/repos","events_url":"https://api.github.com/users/webfactory/events{/privacy}","received_events_url":"https://api.github.com/users/webfactory/received_events","type":"Organization","site_admin":false},"repo":{"id":3041501,"name":"symfony","full_name":"webfactory/symfony","owner":{"login":"webfactory","id":135788,"avatar_url":"https://avatars.githubusercontent.com/u/135788?v=3","gravatar_id":"","url":"https://api.github.com/users/webfactory","html_url":"https://github.com/webfactory","followers_url":"https://api.github.com/users/webfactory/followers","following_url":"https://api.github.com/users/webfactory/following{/other_user}","gists_url":"https://api.github.com/users/webfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/webfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webfactory/subscriptions","organizations_url":"https://api.github.com/users/webfactory/orgs","repos_url":"https://api.github.com/users/webfactory/repos","events_url":"https://api.github.com/users/webfactory/events{/privacy}","received_events_url":"https://api.github.com/users/webfactory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/webfactory/symfony","description":"The Symfony2 PHP framework","fork":true,"url":"https://api.github.com/repos/webfactory/symfony","forks_url":"https://api.github.com/repos/webfactory/symfony/forks","keys_url":"https://api.github.com/repos/webfactory/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webfactory/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webfactory/symfony/teams","hooks_url":"https://api.github.com/repos/webfactory/symfony/hooks","issue_events_url":"https://api.github.com/repos/webfactory/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/webfactory/symfony/events","assignees_url":"https://api.github.com/repos/webfactory/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/webfactory/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/webfactory/symfony/tags","blobs_url":"https://api.github.com/repos/webfactory/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webfactory/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webfactory/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/webfactory/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webfactory/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/webfactory/symfony/languages","stargazers_url":"https://api.github.com/repos/webfactory/symfony/stargazers","contributors_url":"https://api.github.com/repos/webfactory/symfony/contributors","subscribers_url":"https://api.github.com/repos/webfactory/symfony/subscribers","subscription_url":"https://api.github.com/repos/webfactory/symfony/subscription","commits_url":"https://api.github.com/repos/webfactory/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/webfactory/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/webfactory/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/webfactory/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/webfactory/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/webfactory/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webfactory/symfony/merges","archive_url":"https://api.github.com/repos/webfactory/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webfactory/symfony/downloads","issues_url":"https://api.github.com/repos/webfactory/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/webfactory/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/webfactory/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/webfactory/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webfactory/symfony/labels{/name}","releases_url":"https://api.github.com/repos/webfactory/symfony/releases{/id}","created_at":"2011-12-23T17:57:42Z","updated_at":"2014-09-30T06:38:40Z","pushed_at":"2015-04-04T17:32:34Z","git_url":"git://github.com/webfactory/symfony.git","ssh_url":"git@github.com:webfactory/symfony.git","clone_url":"https://github.com/webfactory/symfony.git","svn_url":"https://github.com/webfactory/symfony","homepage":"symfony.com","size":54161,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"4d1344c6a9effb807338d9c8ace840b090cc9631","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-04-05T10:54:45Z","pushed_at":"2015-04-05T10:05:02Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":215840,"stargazers_count":9959,"watchers_count":9959,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3899,"mirror_url":null,"open_issues_count":788,"forks":3899,"open_issues":788,"watchers":9959,"default_branch":"2.7"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14178"},"html":{"href":"https://github.com/symfony/symfony/pull/14178"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/14178"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/14178/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14178/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14178/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/e3ac659a136269ae4f78aa2f1a978d7cd597b88d"}}}}