EkinoWordpressBundle
EkinoWordpressBundle copied to clipboard
Overriding manager
Hello,
I'am new with Sf... Could you explain me how can I override the PostManager to use a custom manager like MyPostManager ?
Which argument should I put in services.yml file ?
MyPostManager: class: %MyPostManager.class% arguments: [? ; ? ; ?]
Thank you Ben
Hi bennet,
i created a PostManager wich extends the wordpressbundle BaseManager. Then in my services.yml i wrote :
custom_post_manager:
class: AppBundle\Manager\PostManager
arguments: ["@doctrine.orm.entity_manager", "%post_entity%", "@ekino.wordpress.manager.post_meta"]
It works for me
Hi @benbet, you can do a new class that extends the base class BaseManager
so you can declare into services.yml the parent class with key parent
and if you need to other dependencies you can put them into class with setter injection. In this mode you don't need to declare the same dependency injection of the parent class.
I do an example for you.
my_manager:
parent: base_manager
class: AppBundle\Services\MyNewManager
calls:
- [setMyClass, ['@my_class']]
http://symfony.com/doc/current/components/dependency_injection/types.html#setter-injection http://symfony.com/doc/current/components/dependency_injection/parentservices.html
Bonjour t-n-y,
Merci pour ta réponse, j'ai appliqué ce que tu m'as recommandé mais j'ai toujours une erreur 500 ...
Pourrais-tu me montrer le contenu de ton PostManager et le contenu de ton fichier config ?
Grand merci pour ton aide (en français c'est plus facile pour moi ;-) )
Ben