{"action":"created","issue":{"url":"https://api.github.com/repos/puli/discovery/issues/9","labels_url":"https://api.github.com/repos/puli/discovery/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/puli/discovery/issues/9/comments","events_url":"https://api.github.com/repos/puli/discovery/issues/9/events","html_url":"https://github.com/puli/discovery/pull/9","id":108295667,"number":9,"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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-09-25T09:52:44Z","updated_at":"2015-09-29T17:01:12Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/puli/discovery/pulls/9","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"},"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."},"comment":{"url":"https://api.github.com/repos/puli/discovery/issues/comments/144121230","html_url":"https://github.com/puli/discovery/pull/9#issuecomment-144121230","issue_url":"https://api.github.com/repos/puli/discovery/issues/9","id":144121230,"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},"created_at":"2015-09-29T17:01:12Z","updated_at":"2015-09-29T17:01:12Z","body":"@GrahamCampbell I don't have one"}}