-
Notifications
You must be signed in to change notification settings - Fork 125
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
Doctrine ORM Manager named "default" does not exist. #806
Comments
Hi @Crash21 In the You can define your own entity manager name here. |
Hello @sescandell, No its not working. I have researched it deeper and found on Guesser/DoctrineORMFieldGuesser.php line 164
|
Hello, Any suggestions how to fix this? If possible give me some guidelines from your point of you as you are more experienced with the Bundle and I will fix it. Thanks. |
A workaround would be to:
class DoctrineORMFieldGuesser extends BaseDoctrineORMFieldGuesser
{
public function getFormOptions($formType, $dbType, $columnName)
{
$formOptions = parent::getFormOptions($formType, $dbType, $columnName);
if (array_key_exists('em', $formOptions)) {
$formOptions['em'] = $this->doctrine->getManagerForClass($formOptions['class']);
}
return $formOptions;
}
} Let me know if it works, I'll create the right PR |
Hmm not really understood :( Well what i did is I added in my parameters.yml
What i get is the following error: Notice: Undefined property: DoctrineORMFieldGuesser::$doctrine in DoctrineORMFieldGuesser.php line 27 So $this->doctrine seems not working, trying to figure it out. Well we can use
but $this->container->get("doctrine")->getManagerForClass($formOptions["class"]); returns an EntityManager object not a string with connection name... We need find a way to get connection string not instance |
Yes, actually Here is a workaround... waiting for a real fix in the admingen (bubbling the configuration to form generation). // in your field guesser custom class:
public function getFormOptions($formType, $dbType, $columnName)
{
$formOptions = parent::getFormOptions($formType, $dbType, $columnName);
if (array_key_exists('em', $formOptions)) {
$formOptions['em'] = $this->getObjectManagerName($formOptions['class']);
}
return $formOptions;
}
protected function getObjectManagerName($className)
{
$doctrine = $this->container->get('doctrine');
$om = $doctrine->getManagerForClass($className);
foreach ($doctrine->getManagerNames() as $omName) {
if ($doctrine->getManager($omName) == $om) {
return $omName;
}
}
throw new \Exception('We should never be there');
} Of course, this is a workaround. You might consider adding some cache capacities (or create a PR to bubble the generator configuration to the form generation :) ) Let me know if it works |
Hey I did some fixes and this seems to be working fine:
So next step is what now? Move these changes in actual AdminBuilder and PR? |
|
Hello,
I have multiple entity managers I have a generator which has a field
When i load the page I get this error:
Doctrine ORM Manager named "default" does not exist.
I haven't found a way in new docs to add em or entity manager to generator. How can i change default to the right one?
The text was updated successfully, but these errors were encountered: