Missing argument 1 for Sonata\DoctrineORMAdminBundle\Model\ModelManager::getEntityManager(),

1,093 views
Skip to first unread message

Tomasz Ignatiuk

unread,
Apr 2, 2012, 3:34:42 PM4/2/12
to sonata...@googlegroups.com
Hi guys,

In AdminBundle with Symfony 2.0 I have used a query in admin class in order to get sorted Entities of a foreging obejcts.

    protected function configureFormFields(FormMapper $formMapper)
    {
        $query_odznaczenie = $this->modelManager->getEntityManager()->createQuery('SELECT s FROM MyCompany\MyBundle\Entity\Odznaczenie s ORDER BY s.opis ASC');
        $query_tag = $this->modelManager->getEntityManager()->createQuery('SELECT s FROM MyCompany\MyBundle\Entity\Tag s ORDER BY s.nazwa ASC');
        $formMapper
            ->with('Relacje')
                ->add('odznaczenie', 'sonata_type_model', array('required' => false, 'query' => $query_odznaczenie), array('edit' => 'inline'))
                ->add('tag', 'sonata_type_model', array('required' => false, 'query' => $query_tag), array('edit' => 'inline'))
            ->end()
            ));
    }

It worked. But when I have updated to Symfony 2.1 and to dev-master of admin bundle I get this error:

Warning: Missing argument 1 for Sonata\DoctrineORMAdminBundle\Model\ModelManager::getEntityManager(), called in C:\wamp\www\projekt\src\MyCompany\MyBundle\Admin\AutorAdmin.php on line 57 and defined in C:\wamp\www\projekt\vendor\sonata-project\doctrine-orm-admin-bundle\Sonata\DoctrineORMAdminBundle\Model\ModelManager.php line 166


Thomas Rabaix

unread,
Apr 2, 2012, 4:28:30 PM4/2/12
to sonata...@googlegroups.com
Sonata's Bundles are not compatible with Symfony2.1


--
You received this message because you are subscribed to the Google Groups "sonata-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sonata-users/-/ygTIHxl3UhUJ.
To post to this group, send email to sonata...@googlegroups.com.
To unsubscribe from this group, send email to sonata-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sonata-users?hl=en.



--
Thomas Rabaix
http://rabaix.net | http://sonata-project.org

Tomasz Ignatiuk

unread,
Apr 3, 2012, 5:15:05 PM4/3/12
to sonata...@googlegroups.com
OK, I went back to Symfony 2.0, upgraded it to 2.0.12, then switched to 2.0 Branches for Admin and Doctrine Bundles, like this:

[SonataAdminBundle]
    git=git://github.com/sonata-project/SonataAdminBundle.git
    target=/bundles/Sonata/AdminBundle
    version=origin/2.0

[SonataDoctrineORMAdminBundle]
    git=http://github.com/sonata-project/SonataDoctrineORMAdminBundle.git
    target=/bundles/Sonata/DoctrineORMAdminBundle
    version=origin/2.0

And still has this error
To unsubscribe from this group, send email to sonata-users+unsubscribe@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sonata-users?hl=en.

Thomas Rabaix

unread,
Apr 3, 2012, 5:32:01 PM4/3/12
to sonata...@googlegroups.com
well looking at the error :

Missing argument 1 for Sonata\DoctrineORMAdminBundle\Model\ModelManager::getEntityManager(), called in C:\wamp\www\projekt\src\MyCompany\MyBundle\Admin\AutorAdmin.php

You are calling the the getEntityManager without an argument... so nothing to do with the AdminBundle.

To view this discussion on the web visit https://groups.google.com/d/msg/sonata-users/-/mkE4tUGo5nEJ.

To post to this group, send email to sonata...@googlegroups.com.
To unsubscribe from this group, send email to sonata-users...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/sonata-users?hl=en.

Tomasz Ignatiuk

unread,
Apr 3, 2012, 6:34:16 PM4/3/12
to sonata...@googlegroups.com
Yes, but previously it worked. Now it doesn't, so something changed. Any one know how to use it? How to put there proper parameter in Admin Class?

Tomasz Ignatiuk

unread,
Apr 4, 2012, 3:22:02 AM4/4/12
to sonata...@googlegroups.com
OK I have got it :)

I had to put there name of the class. Last time I have tried this but SYmfony 2.1 broke other stuff. Now when I have got back to Symfony 2.0.12 it works :)

$query_odznaczenie = $this->modelManager->getEntityManager('MyCompany\MyBundle\Entity\Odznaczenie')->createQuery('SELECT s FROM MyCompany\MyBundle\Entity\Odznaczenie s ORDER BY s.opis ASC');
Reply all
Reply to author
Forward
0 new messages