Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:15:47+00:00 2026-06-15T21:15:47+00:00

Is there any way to call service inside entity I need entity Manager inside

  • 0

Is there any way to call service inside entity

I need entity Manager inside entity so I can able to get custom result with repository functions.

I am thinking about inject ContainerInterface inside my entity like this.

use Symfony\Component\DependencyInjection\ContainerInterface;

class MyEntity
{
    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function getEntityManager(){
        return $this->container->get('doctrine')->getEntityManager();
    }
} 

But I think this is not right way to do that and it take more code I mean I have to do this for all entity where I need entity Manager

Is there any good solution ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:15:48+00:00Added an answer on June 15, 2026 at 9:15 pm

    I don’t know if you can but you shouldn’t do it anyway. The entities are meant to be really simple…

    need entity Manager inside entity so i can able to get custom result with repository functions

    What do you want to do exactly, there must be a different solution…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way to send a web-service call to salesforce n get a
Opah! Is there any way I can call a method in the controller through
Is there any way that I can call a JavaScript function via css? For
Is there any way I can make Firefox call a JavaScript function in my
Is there any way to call an action script function from an anchor which
Is there any way to call a php class (eg. $var = new className)
is there any way to call servlet or make a gwt-rpc call from gwt
I am embedding Lua into a C/C++ application. Is there any way to call
Is there any way to tell db4o to call class default constructor while activating
Is there any way of finding the signature of a called method through call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.