EkinoWordpressBundle icon indicating copy to clipboard operation
EkinoWordpressBundle copied to clipboard

Overriding manager

Open benbet opened this issue 8 years ago • 3 comments

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

benbet avatar Apr 27 '16 20:04 benbet

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

t-n-y avatar May 04 '16 09:05 t-n-y

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

giovannialbero1992 avatar May 22 '16 15:05 giovannialbero1992

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

benbet avatar May 26 '16 19:05 benbet