{"action":"created","comment":{"url":"https://api.github.com/repos/puli/discovery/pulls/comments/40494201","id":40494201,"diff_hunk":"@@ -0,0 +1,112 @@\n+<?php\n+\n+/*\n+ * This file is part of the puli/discovery package.\n+ *\n+ * (c) Bernhard Schussek <bschussek@gmail.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 Puli\\Discovery\\Api\\Binding;\n+\n+use Puli\\Discovery\\Api\\Binding\\Initializer\\NotInitializedException;\n+use Puli\\Discovery\\Api\\Type\\BindingType;\n+use Puli\\Discovery\\Api\\Type\\MissingParameterException;\n+use Puli\\Discovery\\Api\\Type\\NoSuchParameterException;\n+use Puli\\Discovery\\Api\\Type\\NoSuchTypeException;\n+use Rhumsaa\\Uuid\\Uuid;\n+use Serializable;\n+\n+/**\n+ * Binds an artifact to a binding type.\n+ *\n+ * @since  1.0\n+ *\n+ * @author Bernhard Schussek <bschussek@gmail.com>\n+ */\n+interface Binding extends Serializable\n+{\n+    /**\n+     * Initializes the binding.\n+     *\n+     * This method must be called after constructing or unserializing the\n+     * binding.\n+     *\n+     * @param BindingType $type The binding type.\n+     *\n+     * @throws NoSuchParameterException  If a parameter is set that does not\n+     *                                   exist on the loaded type.\n+     * @throws MissingParameterException If a required parameter of the loaded\n+     *                                   type is not set on the binding.\n+     * @throws NoSuchTypeException       If the type of the binding is not found.\n+     */\n+    public function initialize(BindingType $type);\n+\n+    /**\n+     * Returns whether the binding is initialized.\n+     *\n+     * @return bool Returns `true` if the binding is initialized and `false`\n+     *              otherwise.\n+     */\n+    public function isInitialized();\n+\n+    /**\n+     * Returns the UUID of the binding.\n+     *\n+     * @return Uuid The binding UUID.\n+     */\n+    public function getUuid();\n+\n+    /**\n+     * Returns the class name of the bound type.\n+     *\n+     * @return string The class name of the bound type.","path":"src/Api/Binding/Binding.php","position":65,"original_position":65,"commit_id":"93a0b755f69fc3ca23cd8194b03515fb28cd777d","original_commit_id":"93a0b755f69fc3ca23cd8194b03515fb28cd777d","user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"body":"you are still talking about class name here","created_at":"2015-09-26T14:50:12Z","updated_at":"2015-09-26T14:50:12Z","html_url":"https://github.com/puli/discovery/pull/9#discussion_r40494201","pull_request_url":"https://api.github.com/repos/puli/discovery/pulls/9","_links":{"self":{"href":"https://api.github.com/repos/puli/discovery/pulls/comments/40494201"},"html":{"href":"https://github.com/puli/discovery/pull/9#discussion_r40494201"},"pull_request":{"href":"https://api.github.com/repos/puli/discovery/pulls/9"}}},"pull_request":{"url":"https://api.github.com/repos/puli/discovery/pulls/9","id":45994679,"html_url":"https://github.com/puli/discovery/pull/9","diff_url":"https://github.com/puli/discovery/pull/9.diff","patch_url":"https://github.com/puli/discovery/pull/9.patch","issue_url":"https://api.github.com/repos/puli/discovery/issues/9","number":9,"state":"open","locked":false,"title":"Rewrote the Discovery implementation to be more flexible","user":{"login":"webmozart","id":176399,"avatar_url":"https://avatars.githubusercontent.com/u/176399?v=3","gravatar_id":"","url":"https://api.github.com/users/webmozart","html_url":"https://github.com/webmozart","followers_url":"https://api.github.com/users/webmozart/followers","following_url":"https://api.github.com/users/webmozart/following{/other_user}","gists_url":"https://api.github.com/users/webmozart/gists{/gist_id}","starred_url":"https://api.github.com/users/webmozart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmozart/subscriptions","organizations_url":"https://api.github.com/users/webmozart/orgs","repos_url":"https://api.github.com/users/webmozart/repos","events_url":"https://api.github.com/users/webmozart/events{/privacy}","received_events_url":"https://api.github.com/users/webmozart/received_events","type":"User","site_admin":false},"body":"Fixes puli/issues#114 (read this ticket first for background information).\r\n\r\nThis PR decouples the Discovery completely from the resource repository. Resources are only one type of \"artifact\" that can be bound to a binding type. Another type of artifact supported by default is class names.\r\n\r\nBinding types don't have simple string names anymore, but fully-qualified PHP identifiers (class names). These class names may or may not correspond to existing classes/interfaces. Creating actual interfaces makes the use of binding types easier as of PHP 5.5, as then we can use the `::class` constant.\r\n\r\nExample with class names:\r\n\r\n```php\r\n// in the consumer package\r\n$discovery->addBindingType(new BindingType(Plugin::class));\r\n\r\n// in the provider packages\r\n$discovery->addBinding(new ClassBinding(PaymentPlugin::class, Plugin::class));\r\n$discovery->addBinding(new ClassBinding(SecurityPlugin::class, Plugin::class));\r\n$discovery->addBinding(new ClassBinding(AdPlugin::class, Plugin::class));\r\n\r\n// in the consumer package\r\nforeach ($discovery->findBindings(Plugin::class) as $binding) {\r\n    $className = $binding->getClassName();\r\n    $plugin = new $className();\r\n\r\n    // ...\r\n}\r\n```\r\n\r\nExample with resources:\r\n\r\n```php\r\n// in the consumer package\r\n$discovery->addBindingType(new BindingType(MessageCatalog::class));\r\n\r\n// in the provider packages\r\n$discovery->addBinding(new ResourceBinding('/app/trans/*.yml', MessageCatalog::class));\r\n$discovery->addBinding(new ResourceBinding('/batman/blog/trans/*.yml', MessageCatalog::class));\r\n\r\n// in the consumer package\r\nforeach ($discovery->findBindings(MessageCatalog::class) as $binding) {\r\n    // Iterate the resources matched by the globs\r\n    foreach ($binding->getResources() as $resource) {\r\n        $messages = Yaml::load($resource->getBody());\r\n\r\n        // ...\r\n    }\r\n}\r\n```\r\n\r\nThis PR is finished except for PHPDoc and the CHANGELOG. Please review.","created_at":"2015-09-25T09:52:44Z","updated_at":"2015-09-26T14:50:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9a41302da7e1c9b31d0baf4ff382ccebe8c49c91","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/puli/discovery/pulls/9/commits","review_comments_url":"https://api.github.com/repos/puli/discovery/pulls/9/comments","review_comment_url":"https://api.github.com/repos/puli/discovery/pulls/comments{/number}","comments_url":"https://api.github.com/repos/puli/discovery/issues/9/comments","statuses_url":"https://api.github.com/repos/puli/discovery/statuses/93a0b755f69fc3ca23cd8194b03515fb28cd777d","head":{"label":"puli:rewrite","ref":"rewrite","sha":"93a0b755f69fc3ca23cd8194b03515fb28cd777d","user":{"login":"puli","id":9706065,"avatar_url":"https://avatars.githubusercontent.com/u/9706065?v=3","gravatar_id":"","url":"https://api.github.com/users/puli","html_url":"https://github.com/puli","followers_url":"https://api.github.com/users/puli/followers","following_url":"https://api.github.com/users/puli/following{/other_user}","gists_url":"https://api.github.com/users/puli/gists{/gist_id}","starred_url":"https://api.github.com/users/puli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puli/subscriptions","organizations_url":"https://api.github.com/users/puli/orgs","repos_url":"https://api.github.com/users/puli/repos","events_url":"https://api.github.com/users/puli/events{/privacy}","received_events_url":"https://api.github.com/users/puli/received_events","type":"Organization","site_admin":false},"repo":{"id":28141175,"name":"discovery","full_name":"puli/discovery","owner":{"login":"puli","id":9706065,"avatar_url":"https://avatars.githubusercontent.com/u/9706065?v=3","gravatar_id":"","url":"https://api.github.com/users/puli","html_url":"https://github.com/puli","followers_url":"https://api.github.com/users/puli/followers","following_url":"https://api.github.com/users/puli/following{/other_user}","gists_url":"https://api.github.com/users/puli/gists{/gist_id}","starred_url":"https://api.github.com/users/puli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puli/subscriptions","organizations_url":"https://api.github.com/users/puli/orgs","repos_url":"https://api.github.com/users/puli/repos","events_url":"https://api.github.com/users/puli/events{/privacy}","received_events_url":"https://api.github.com/users/puli/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puli/discovery","description":"Discovers Puli resources bound to predefined types.","fork":false,"url":"https://api.github.com/repos/puli/discovery","forks_url":"https://api.github.com/repos/puli/discovery/forks","keys_url":"https://api.github.com/repos/puli/discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puli/discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puli/discovery/teams","hooks_url":"https://api.github.com/repos/puli/discovery/hooks","issue_events_url":"https://api.github.com/repos/puli/discovery/issues/events{/number}","events_url":"https://api.github.com/repos/puli/discovery/events","assignees_url":"https://api.github.com/repos/puli/discovery/assignees{/user}","branches_url":"https://api.github.com/repos/puli/discovery/branches{/branch}","tags_url":"https://api.github.com/repos/puli/discovery/tags","blobs_url":"https://api.github.com/repos/puli/discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puli/discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puli/discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/puli/discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puli/discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/puli/discovery/languages","stargazers_url":"https://api.github.com/repos/puli/discovery/stargazers","contributors_url":"https://api.github.com/repos/puli/discovery/contributors","subscribers_url":"https://api.github.com/repos/puli/discovery/subscribers","subscription_url":"https://api.github.com/repos/puli/discovery/subscription","commits_url":"https://api.github.com/repos/puli/discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/puli/discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/puli/discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/puli/discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/puli/discovery/contents/{+path}","compare_url":"https://api.github.com/repos/puli/discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puli/discovery/merges","archive_url":"https://api.github.com/repos/puli/discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puli/discovery/downloads","issues_url":"https://api.github.com/repos/puli/discovery/issues{/number}","pulls_url":"https://api.github.com/repos/puli/discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/puli/discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/puli/discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puli/discovery/labels{/name}","releases_url":"https://api.github.com/repos/puli/discovery/releases{/id}","created_at":"2014-12-17T14:43:18Z","updated_at":"2015-07-19T22:30:23Z","pushed_at":"2015-09-26T13:54:51Z","git_url":"git://github.com/puli/discovery.git","ssh_url":"git@github.com:puli/discovery.git","clone_url":"https://github.com/puli/discovery.git","svn_url":"https://github.com/puli/discovery","homepage":"","size":576,"stargazers_count":6,"watchers_count":6,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":6,"default_branch":"master"}},"base":{"label":"puli:master","ref":"master","sha":"fc637d28922dd5c7ca5510ef32e42b40226b659f","user":{"login":"puli","id":9706065,"avatar_url":"https://avatars.githubusercontent.com/u/9706065?v=3","gravatar_id":"","url":"https://api.github.com/users/puli","html_url":"https://github.com/puli","followers_url":"https://api.github.com/users/puli/followers","following_url":"https://api.github.com/users/puli/following{/other_user}","gists_url":"https://api.github.com/users/puli/gists{/gist_id}","starred_url":"https://api.github.com/users/puli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puli/subscriptions","organizations_url":"https://api.github.com/users/puli/orgs","repos_url":"https://api.github.com/users/puli/repos","events_url":"https://api.github.com/users/puli/events{/privacy}","received_events_url":"https://api.github.com/users/puli/received_events","type":"Organization","site_admin":false},"repo":{"id":28141175,"name":"discovery","full_name":"puli/discovery","owner":{"login":"puli","id":9706065,"avatar_url":"https://avatars.githubusercontent.com/u/9706065?v=3","gravatar_id":"","url":"https://api.github.com/users/puli","html_url":"https://github.com/puli","followers_url":"https://api.github.com/users/puli/followers","following_url":"https://api.github.com/users/puli/following{/other_user}","gists_url":"https://api.github.com/users/puli/gists{/gist_id}","starred_url":"https://api.github.com/users/puli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/puli/subscriptions","organizations_url":"https://api.github.com/users/puli/orgs","repos_url":"https://api.github.com/users/puli/repos","events_url":"https://api.github.com/users/puli/events{/privacy}","received_events_url":"https://api.github.com/users/puli/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/puli/discovery","description":"Discovers Puli resources bound to predefined types.","fork":false,"url":"https://api.github.com/repos/puli/discovery","forks_url":"https://api.github.com/repos/puli/discovery/forks","keys_url":"https://api.github.com/repos/puli/discovery/keys{/key_id}","collaborators_url":"https://api.github.com/repos/puli/discovery/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/puli/discovery/teams","hooks_url":"https://api.github.com/repos/puli/discovery/hooks","issue_events_url":"https://api.github.com/repos/puli/discovery/issues/events{/number}","events_url":"https://api.github.com/repos/puli/discovery/events","assignees_url":"https://api.github.com/repos/puli/discovery/assignees{/user}","branches_url":"https://api.github.com/repos/puli/discovery/branches{/branch}","tags_url":"https://api.github.com/repos/puli/discovery/tags","blobs_url":"https://api.github.com/repos/puli/discovery/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/puli/discovery/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/puli/discovery/git/refs{/sha}","trees_url":"https://api.github.com/repos/puli/discovery/git/trees{/sha}","statuses_url":"https://api.github.com/repos/puli/discovery/statuses/{sha}","languages_url":"https://api.github.com/repos/puli/discovery/languages","stargazers_url":"https://api.github.com/repos/puli/discovery/stargazers","contributors_url":"https://api.github.com/repos/puli/discovery/contributors","subscribers_url":"https://api.github.com/repos/puli/discovery/subscribers","subscription_url":"https://api.github.com/repos/puli/discovery/subscription","commits_url":"https://api.github.com/repos/puli/discovery/commits{/sha}","git_commits_url":"https://api.github.com/repos/puli/discovery/git/commits{/sha}","comments_url":"https://api.github.com/repos/puli/discovery/comments{/number}","issue_comment_url":"https://api.github.com/repos/puli/discovery/issues/comments{/number}","contents_url":"https://api.github.com/repos/puli/discovery/contents/{+path}","compare_url":"https://api.github.com/repos/puli/discovery/compare/{base}...{head}","merges_url":"https://api.github.com/repos/puli/discovery/merges","archive_url":"https://api.github.com/repos/puli/discovery/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/puli/discovery/downloads","issues_url":"https://api.github.com/repos/puli/discovery/issues{/number}","pulls_url":"https://api.github.com/repos/puli/discovery/pulls{/number}","milestones_url":"https://api.github.com/repos/puli/discovery/milestones{/number}","notifications_url":"https://api.github.com/repos/puli/discovery/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/puli/discovery/labels{/name}","releases_url":"https://api.github.com/repos/puli/discovery/releases{/id}","created_at":"2014-12-17T14:43:18Z","updated_at":"2015-07-19T22:30:23Z","pushed_at":"2015-09-26T13:54:51Z","git_url":"git://github.com/puli/discovery.git","ssh_url":"git@github.com:puli/discovery.git","clone_url":"https://github.com/puli/discovery.git","svn_url":"https://github.com/puli/discovery","homepage":"","size":576,"stargazers_count":6,"watchers_count":6,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/puli/discovery/pulls/9"},"html":{"href":"https://github.com/puli/discovery/pull/9"},"issue":{"href":"https://api.github.com/repos/puli/discovery/issues/9"},"comments":{"href":"https://api.github.com/repos/puli/discovery/issues/9/comments"},"review_comments":{"href":"https://api.github.com/repos/puli/discovery/pulls/9/comments"},"review_comment":{"href":"https://api.github.com/repos/puli/discovery/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/puli/discovery/pulls/9/commits"},"statuses":{"href":"https://api.github.com/repos/puli/discovery/statuses/93a0b755f69fc3ca23cd8194b03515fb28cd777d"}}}}