Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants