0

Is there a way to access sessions or configuration parameters from inside the Entity? I would like to have access to app.session.xyz in every Entity in all of my bundles. Is it possible to configure doctrine or create some service to archive this?

1
  • 1
    At best you can do is creating event listener service and inject the services you want to access. See this cookbook entry. Commented May 31, 2012 at 8:09

1 Answer 1

1

It's a bad idea. Your entities must not contains any logic. All your business logic should live inside dedicated services.

Anyway, it's not possible. You can't use the DIC to inject services into entities because it do not know how to create them.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.