{"action":"created","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/6015","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/6015/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/6015/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/6015/events","html_url":"https://github.com/cakephp/cakephp/issues/6015","id":59962897,"number":6015,"title":"3.x Allow removal of single event listeners","user":{"login":"davidyell","id":49889,"avatar_url":"https://avatars.githubusercontent.com/u/49889?v=3","gravatar_id":"","url":"https://api.github.com/users/davidyell","html_url":"https://github.com/davidyell","followers_url":"https://api.github.com/users/davidyell/followers","following_url":"https://api.github.com/users/davidyell/following{/other_user}","gists_url":"https://api.github.com/users/davidyell/gists{/gist_id}","starred_url":"https://api.github.com/users/davidyell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidyell/subscriptions","organizations_url":"https://api.github.com/users/davidyell/orgs","repos_url":"https://api.github.com/users/davidyell/repos","events_url":"https://api.github.com/users/davidyell/events{/privacy}","received_events_url":"https://api.github.com/users/davidyell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/cakephp/cakephp/labels/Question","name":"Question","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/7","html_url":"https://github.com/cakephp/cakephp/milestones/3.0.0","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/7/labels","id":453043,"number":7,"title":"3.0.0","description":"New major release that breaks compatibility with 2.x\r\n\r\n- PHP5.4.19+\r\n- New ORM & behaviors.\r\n- Improved Routing\r\n- PSR-0 and composer support.\r\n- Simpler configuration and bootstrapping.\r\n- Improved configuration handling.\r\n- Improved bake.\r\n\r\nSee [the roadmap](http://github.com/cakephp/cakephp/wiki/3.0-roadmap) for more details.","creator":{"login":"lh-import","id":5175817,"avatar_url":"https://avatars.githubusercontent.com/u/5175817?v=3","gravatar_id":"","url":"https://api.github.com/users/lh-import","html_url":"https://github.com/lh-import","followers_url":"https://api.github.com/users/lh-import/followers","following_url":"https://api.github.com/users/lh-import/following{/other_user}","gists_url":"https://api.github.com/users/lh-import/gists{/gist_id}","starred_url":"https://api.github.com/users/lh-import/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lh-import/subscriptions","organizations_url":"https://api.github.com/users/lh-import/orgs","repos_url":"https://api.github.com/users/lh-import/repos","events_url":"https://api.github.com/users/lh-import/events{/privacy}","received_events_url":"https://api.github.com/users/lh-import/received_events","type":"User","site_admin":false},"open_issues":17,"closed_issues":2388,"state":"open","created_at":"2013-10-11T20:56:23Z","updated_at":"2015-03-06T02:12:46Z","due_on":"2015-03-22T04:00:00Z","closed_at":null},"comments":8,"created_at":"2015-03-05T14:58:26Z","updated_at":"2015-03-06T02:15:22Z","closed_at":null,"body":"Currently I don't believe that it's possible to remove a single event listener without having the same instance available.\r\n\r\nThis means that if you are emitting events and someone else wants to replace your listener they must remove all the attached events and readd the ones they want.\r\n\r\nSo the way I currently understand the events api is thus,\r\n```php\r\n// ExampleTable.php\r\npublic function initialize(array $config)\r\n{\r\n    //etc\r\n    $this->eventManager()->off('Some.CustomEvent');\r\n\r\n    $listener = new App\\Event\\DefaultListener();\r\n    $this->eventManager()->on($listener);\r\n\r\n    $listener = new App\\Event\\ReplacementListener();\r\n    $this->eventManager()->on($listener);\r\n```\r\n\r\nIt would be nice to have an api similar to this I think,\r\n\r\n```php\r\n// ExampleTable.php\r\npublic function initialize(array $config)\r\n{\r\n    //etc\r\n    $this->eventManager()->off('Some.CustomEvent', 'App\\Event\\CustomListener');\r\n```\r\n\r\nI haven't had too much time to look through the Event Manager yet, but I wanted to start a discussion before I tried any code changes to ensure that any work would be on the right track.\r\n\r\nProbably a 3.1 target release I'd think."},"comment":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/comments/77494561","html_url":"https://github.com/cakephp/cakephp/issues/6015#issuecomment-77494561","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/6015","id":77494561,"user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"created_at":"2015-03-06T02:15:22Z","updated_at":"2015-03-06T02:15:22Z","body":"How can you remove a listener without the instance? Inferring which object to remove based on class name gets pretty hard with Closure. "}}