Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any idea how to use one of the services in EventSubscriber action? #135

Open
phtmgt opened this issue Oct 13, 2017 · 1 comment
Open

Any idea how to use one of the services in EventSubscriber action? #135

phtmgt opened this issue Oct 13, 2017 · 1 comment

Comments

@phtmgt
Copy link

phtmgt commented Oct 13, 2017

Trying to do this in Symfony 3.3 we always get "Attempted to call an undefined method named "get" of class "AppBundle\EventSubscriber\SitemapBlogPostsSubscriber""

The call in question is this: $postManager = $this->get('ekino.wordpress.manager.post');

We tried defining 'ekino.wordpress.manager.post' as an attribute for the service in services.yml, but no luck.

Any suggestions are highly appreciated.

Thanks.

@wiejakp
Copy link

wiejakp commented Nov 6, 2017

You will only be able to access services through "$this->get()" if your SitemapBlogPostsSubscriber class inherits from ContainerAwareInterface. Instead of doing that, you could inject service ekino.wordpress.manager.post into your class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants