{"action":"created","issue":{"url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/167","labels_url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/167/labels{/name}","comments_url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/167/comments","events_url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/167/events","html_url":"https://github.com/juriansluiman/SlmQueue/issues/167","id":104187327,"number":167,"title":"Documentation question - How to get to the queue from a service class (outside of controller plugin)","user":{"login":"jackdpeterson","id":938961,"avatar_url":"https://avatars.githubusercontent.com/u/938961?v=3","gravatar_id":"","url":"https://api.github.com/users/jackdpeterson","html_url":"https://github.com/jackdpeterson","followers_url":"https://api.github.com/users/jackdpeterson/followers","following_url":"https://api.github.com/users/jackdpeterson/following{/other_user}","gists_url":"https://api.github.com/users/jackdpeterson/gists{/gist_id}","starred_url":"https://api.github.com/users/jackdpeterson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackdpeterson/subscriptions","organizations_url":"https://api.github.com/users/jackdpeterson/orgs","repos_url":"https://api.github.com/users/jackdpeterson/repos","events_url":"https://api.github.com/users/jackdpeterson/events{/privacy}","received_events_url":"https://api.github.com/users/jackdpeterson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-01T05:00:49Z","updated_at":"2015-09-01T07:19:49Z","closed_at":null,"body":"First of all, thanks to all of the contributors on this project. This is an absolutely fantastic module.\r\n\r\nI do have one question after pouring through the documentation and perhaps someone has an answer to this.\r\n\r\nI have most of my core busines functionality ran from service classes that are fat and really thin controller methods (Apigility REST api -- code connected). How does one access the Queue from a service like this? My initial assumption was to make my service implement the QueueAwareInterface; however, that didn't do what I expected. In fact, nothing appeared to happen --- no queue was injected using setter method injection.\r\n\r\nMy questions are as follows:\r\n1. What should I reference to get the queue to be able to push ($queue = $this->getServiceLocator()->get('queue');\r\n\r\n2. Is there an X-aware interface implementation that has already been incorporated but just not documented using ZF2 initializers?"},"comment":{"url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/comments/136611395","html_url":"https://github.com/juriansluiman/SlmQueue/issues/167#issuecomment-136611395","issue_url":"https://api.github.com/repos/juriansluiman/SlmQueue/issues/167","id":136611395,"user":{"login":"bakura10","id":1198915,"avatar_url":"https://avatars.githubusercontent.com/u/1198915?v=3","gravatar_id":"","url":"https://api.github.com/users/bakura10","html_url":"https://github.com/bakura10","followers_url":"https://api.github.com/users/bakura10/followers","following_url":"https://api.github.com/users/bakura10/following{/other_user}","gists_url":"https://api.github.com/users/bakura10/gists{/gist_id}","starred_url":"https://api.github.com/users/bakura10/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bakura10/subscriptions","organizations_url":"https://api.github.com/users/bakura10/orgs","repos_url":"https://api.github.com/users/bakura10/repos","events_url":"https://api.github.com/users/bakura10/events{/privacy}","received_events_url":"https://api.github.com/users/bakura10/received_events","type":"User","site_admin":false},"created_at":"2015-09-01T07:19:49Z","updated_at":"2015-09-01T07:19:49Z","body":"Hi !\r\n\r\nThe QueueAwareInterface, as documented here: https://github.com/juriansluiman/SlmQueue/blob/97e16e9d87b39e98184276d36faddb8dd85da23c/docs/4.QueueAware.md only works for job.\r\n\r\nThe problem by using this interface for your service is that even if you create an initializer, how the initializer could know which queue inject into a given service? It cannot know.\r\n\r\nThat's why I think injecting the queue directly is the best way:\r\n\r\n```php\r\nclass MyService\r\n{\r\n  public function __construct(QueueInterface $queue)\r\n  {\r\n  }\r\n}\r\n```\r\n\r\nThis way you can control which queue to inject right into your factory.\r\n\r\nHope it helps! ;)"}}