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

Overriding manager #112

Open
benbet opened this issue Apr 27, 2016 · 3 comments
Open

Overriding manager #112

benbet opened this issue Apr 27, 2016 · 3 comments

Comments

@benbet
Copy link

benbet commented Apr 27, 2016

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

@t-n-y
Copy link
Contributor

t-n-y commented May 4, 2016

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

@giovannialbero1992
Copy link

giovannialbero1992 commented May 22, 2016

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

@benbet
Copy link
Author

benbet commented May 26, 2016

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

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

3 participants