{"action":"created","comment":{"url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/comments/46793690","id":46793690,"diff_hunk":"@@ -29,6 +53,193 @@ public function load(array $configs, ContainerBuilder $container)\n         $loader->load('services.yml');\n \n         $container->setParameter('cache_adapter_doctrine.providers', $config['providers']);\n+\n+        $this->process($container);\n+    }\n+\n+\n+\n+    /**\n+     * For each configured provider, build a service.\n+     *\n+     * @param ContainerBuilder $container\n+     */\n+    protected function process(ContainerBuilder $container)\n+    {\n+        $providers = $container->getParameter('cache_adapter_doctrine.providers');\n+\n+        foreach ($providers as $name => $provider) {\n+            $typeServiceId = sprintf('cache.doctrine_adapter.abstract.%s', $provider['type']);\n+            $classParameter = sprintf('cache.doctrine_adapter.%s.class',$provider['type']);\n+            if (!$container->hasParameter($classParameter)) {\n+                throw new InvalidConfigurationException(\n+                    sprintf(\n+                        '\"%s\" is not a valid cache type. We cannot find a container parameter named \"%s\" with a class namespace as value. Make sure to add that or use any built in services',\n+                        $provider['type'],\n+                        $classParameter\n+                    )\n+                );\n+            }\n+            $class = $container->getParameter($classParameter);\n+\n+            $this->createDoctrineCacheDefinition($container, $typeServiceId, $class, $name, $provider);\n+            $this->createPsr7CompliantService($container, $typeServiceId, $name);\n+        }\n+    }\n+\n+    /**\n+     * Make sure to create a PRS-6 service that wraps the doctrine service.\n+     *\n+     * @param ContainerBuilder $container\n+     * @param string $typeServiceId\n+     * @param string $name\n+     */\n+    private function createPsr7CompliantService(ContainerBuilder $container, $typeServiceId, $name)\n+    {\n+        // This is the service id for the PSR6 provider. This is the one that we use.\n+        $serviceId = 'cache.doctrine_adapter.provider.'.$name;\n+\n+        // Register the CacheItemPoolInterface definition\n+        $def = new Definition(\\Cache\\Doctrine\\CachePoolItem::class);\n+        $def->addArgument(new Reference($typeServiceId));\n+        $def->setTags(['cache.provider'=>[]]);\n+\n+        $container->setDefinition($serviceId, $def);\n+        $container->setAlias('cache.provider.'.$name, $serviceId);\n+    }\n+\n+    /**\n+     * We need to prepare the doctrine cache providers.\n+     *\n+     * @param ContainerBuilder $container\n+     * @param string $typeServiceId\n+     * @param string $class\n+     * @param string $name\n+     * @param array $provider\n+     */\n+    private function createDoctrineCacheDefinition(ContainerBuilder $container, $typeServiceId, $class, $name, array $provider)\n+    {\n+        $namespace = is_null($provider['namespace']) ? $name : $provider['namespace'];\n+\n+        // Create a service for the requested doctrine cache\n+        $definition = new Definition($class);\n+        $definition->addMethodCall('setNamespace', [$namespace])\n+            ->setPublic(false);\n+\n+        $type = $provider['type'];\n+        switch ($type) {\n+            case 'memcache':\n+            case 'memcached':\n+            case 'redis':\n+                if (!empty($provider['id'])) {\n+                    $providerHelperServiceId = $provider['id'];\n+                } else {\n+                    // Create a new cache provider if none is defined\n+                    $providerHelperServiceId = sprintf('cache_adapter_doctrine.provider.%s.helper', $name);\n+                    $providerHelperDefinition = $this->createProviderHelperDefinition($type, $provider);\n+                    $container->setDefinition($providerHelperServiceId, $providerHelperDefinition);\n+                }\n+\n+                $definition->addMethodCall(sprintf('set%s', ucwords($type)), [new Reference($providerHelperServiceId)]);\n+                break;\n+            case 'file_system':\n+            case 'php_file':\n+                $directory = '%kernel.cache_dir%/doctrine/cache';\n+                if (null !== $provider['directory']) {\n+                    $directory = $provider['directory'];\n+                }\n+                $extension = is_null($provider['extension']) ? null : $provider['extension'];\n+                $definition->setArguments([$directory, $extension]);\n+\n+                break;\n+            case 'mongo':\n+            case 'sqlite3':\n+            case 'sqlite':\n+            case 'riak':\n+            case 'chain':\n+                break;","path":"src/DependencyInjection/DoctrineAdapterExtension.php","position":146,"original_position":146,"commit_id":"38304ae53ce27b8729070e46de5c2de0874b0647","original_commit_id":"38304ae53ce27b8729070e46de5c2de0874b0647","user":{"login":"aequasi","id":896295,"avatar_url":"https://avatars.githubusercontent.com/u/896295?v=3","gravatar_id":"","url":"https://api.github.com/users/aequasi","html_url":"https://github.com/aequasi","followers_url":"https://api.github.com/users/aequasi/followers","following_url":"https://api.github.com/users/aequasi/following{/other_user}","gists_url":"https://api.github.com/users/aequasi/gists{/gist_id}","starred_url":"https://api.github.com/users/aequasi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aequasi/subscriptions","organizations_url":"https://api.github.com/users/aequasi/orgs","repos_url":"https://api.github.com/users/aequasi/repos","events_url":"https://api.github.com/users/aequasi/events{/privacy}","received_events_url":"https://api.github.com/users/aequasi/received_events","type":"User","site_admin":false},"body":"IIRC these are meant to fail, until we implement them. Should throw an exception instead of breaking.\r\n","created_at":"2015-12-07T07:55:33Z","updated_at":"2015-12-07T07:55:33Z","html_url":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1#discussion_r46793690","pull_request_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/comments/46793690"},"html":{"href":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1#discussion_r46793690"},"pull_request":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1","id":52795355,"html_url":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1","diff_url":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1.diff","patch_url":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1.patch","issue_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/1","number":1,"state":"open","locked":false,"title":"Bugfixes and improvements","user":{"login":"Nyholm","id":1275206,"avatar_url":"https://avatars.githubusercontent.com/u/1275206?v=3","gravatar_id":"","url":"https://api.github.com/users/Nyholm","html_url":"https://github.com/Nyholm","followers_url":"https://api.github.com/users/Nyholm/followers","following_url":"https://api.github.com/users/Nyholm/following{/other_user}","gists_url":"https://api.github.com/users/Nyholm/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyholm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyholm/subscriptions","organizations_url":"https://api.github.com/users/Nyholm/orgs","repos_url":"https://api.github.com/users/Nyholm/repos","events_url":"https://api.github.com/users/Nyholm/events{/privacy}","received_events_url":"https://api.github.com/users/Nyholm/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-12-07T00:12:31Z","updated_at":"2015-12-07T07:55:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"21357d3abc6ec7ad951758b9afcfb5c88f59e002","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1/commits","review_comments_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1/comments","review_comment_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/1/comments","statuses_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/statuses/38304ae53ce27b8729070e46de5c2de0874b0647","head":{"label":"Nyholm:patch","ref":"patch","sha":"38304ae53ce27b8729070e46de5c2de0874b0647","user":{"login":"Nyholm","id":1275206,"avatar_url":"https://avatars.githubusercontent.com/u/1275206?v=3","gravatar_id":"","url":"https://api.github.com/users/Nyholm","html_url":"https://github.com/Nyholm","followers_url":"https://api.github.com/users/Nyholm/followers","following_url":"https://api.github.com/users/Nyholm/following{/other_user}","gists_url":"https://api.github.com/users/Nyholm/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyholm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyholm/subscriptions","organizations_url":"https://api.github.com/users/Nyholm/orgs","repos_url":"https://api.github.com/users/Nyholm/repos","events_url":"https://api.github.com/users/Nyholm/events{/privacy}","received_events_url":"https://api.github.com/users/Nyholm/received_events","type":"User","site_admin":false},"repo":{"id":47518888,"name":"doctrine-adapter-bundle","full_name":"Nyholm/doctrine-adapter-bundle","owner":{"login":"Nyholm","id":1275206,"avatar_url":"https://avatars.githubusercontent.com/u/1275206?v=3","gravatar_id":"","url":"https://api.github.com/users/Nyholm","html_url":"https://github.com/Nyholm","followers_url":"https://api.github.com/users/Nyholm/followers","following_url":"https://api.github.com/users/Nyholm/following{/other_user}","gists_url":"https://api.github.com/users/Nyholm/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyholm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyholm/subscriptions","organizations_url":"https://api.github.com/users/Nyholm/orgs","repos_url":"https://api.github.com/users/Nyholm/repos","events_url":"https://api.github.com/users/Nyholm/events{/privacy}","received_events_url":"https://api.github.com/users/Nyholm/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nyholm/doctrine-adapter-bundle","description":"Doctrine Cache Pool Bundle","fork":true,"url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle","forks_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/forks","keys_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/teams","hooks_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/hooks","issue_events_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/events","assignees_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/tags","blobs_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/languages","stargazers_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/stargazers","contributors_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/contributors","subscribers_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/subscribers","subscription_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/subscription","commits_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/merges","archive_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/downloads","issues_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/labels{/name}","releases_url":"https://api.github.com/repos/Nyholm/doctrine-adapter-bundle/releases{/id}","created_at":"2015-12-06T23:49:04Z","updated_at":"2015-12-06T23:49:05Z","pushed_at":"2015-12-07T01:12:00Z","git_url":"git://github.com/Nyholm/doctrine-adapter-bundle.git","ssh_url":"git@github.com:Nyholm/doctrine-adapter-bundle.git","clone_url":"https://github.com/Nyholm/doctrine-adapter-bundle.git","svn_url":"https://github.com/Nyholm/doctrine-adapter-bundle","homepage":null,"size":24,"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":"php-cache:master","ref":"master","sha":"8f8763a37aa76352afa17baefe4dac5a2eb5929a","user":{"login":"php-cache","id":16170857,"avatar_url":"https://avatars.githubusercontent.com/u/16170857?v=3","gravatar_id":"","url":"https://api.github.com/users/php-cache","html_url":"https://github.com/php-cache","followers_url":"https://api.github.com/users/php-cache/followers","following_url":"https://api.github.com/users/php-cache/following{/other_user}","gists_url":"https://api.github.com/users/php-cache/gists{/gist_id}","starred_url":"https://api.github.com/users/php-cache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-cache/subscriptions","organizations_url":"https://api.github.com/users/php-cache/orgs","repos_url":"https://api.github.com/users/php-cache/repos","events_url":"https://api.github.com/users/php-cache/events{/privacy}","received_events_url":"https://api.github.com/users/php-cache/received_events","type":"Organization","site_admin":false},"repo":{"id":47477084,"name":"doctrine-adapter-bundle","full_name":"php-cache/doctrine-adapter-bundle","owner":{"login":"php-cache","id":16170857,"avatar_url":"https://avatars.githubusercontent.com/u/16170857?v=3","gravatar_id":"","url":"https://api.github.com/users/php-cache","html_url":"https://github.com/php-cache","followers_url":"https://api.github.com/users/php-cache/followers","following_url":"https://api.github.com/users/php-cache/following{/other_user}","gists_url":"https://api.github.com/users/php-cache/gists{/gist_id}","starred_url":"https://api.github.com/users/php-cache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php-cache/subscriptions","organizations_url":"https://api.github.com/users/php-cache/orgs","repos_url":"https://api.github.com/users/php-cache/repos","events_url":"https://api.github.com/users/php-cache/events{/privacy}","received_events_url":"https://api.github.com/users/php-cache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php-cache/doctrine-adapter-bundle","description":"Doctrine Cache Pool Bundle","fork":false,"url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle","forks_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/forks","keys_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/teams","hooks_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/hooks","issue_events_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/events","assignees_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/tags","blobs_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/languages","stargazers_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/stargazers","contributors_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/contributors","subscribers_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/subscribers","subscription_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/subscription","commits_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/merges","archive_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/downloads","issues_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/labels{/name}","releases_url":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/releases{/id}","created_at":"2015-12-05T23:47:02Z","updated_at":"2015-12-06T09:04:59Z","pushed_at":"2015-12-07T01:12:00Z","git_url":"git://github.com/php-cache/doctrine-adapter-bundle.git","ssh_url":"git@github.com:php-cache/doctrine-adapter-bundle.git","clone_url":"https://github.com/php-cache/doctrine-adapter-bundle.git","svn_url":"https://github.com/php-cache/doctrine-adapter-bundle","homepage":null,"size":24,"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/php-cache/doctrine-adapter-bundle/pulls/1"},"html":{"href":"https://github.com/php-cache/doctrine-adapter-bundle/pull/1"},"issue":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/1"},"comments":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/php-cache/doctrine-adapter-bundle/statuses/38304ae53ce27b8729070e46de5c2de0874b0647"}}}}