Closed SchulzWill closed 4 years ago
How does your service definition for ListingAdmin
look like?
Hello there!
This is my service definition of the Listing Admin
sonata.admin.listing:
class: Cocorico\CoreBundle\Admin\ListingAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Listings", label: "Listings" }
arguments:
- ~
- Cocorico\CoreBundle\Entity\Listing
- ~
calls:
- [ setTranslationDomain, [SonataAdminBundle]]
- [ setLocales, ["%cocorico.locales%"]]
- [ setIncludeVat, ["%cocorico.include_vat%"]]
- [ setBundlesEnabled, ["%kernel.bundles%"]]
and the class implementation:
class ListingAdmin extends AbstractAdmin implements AdminWithImport
Hey @SchulzWill,
Didn't use this in a while so I had to read code, basically, your services need to have autoconfigure: true
for:
this to kick in. You can read more about it here.
This attaches a tag based on interface your classes implement but only if autoconfiguration is on.
If you don't have or want to use autoconfigure: true
, an alternate is to tag those services manually. (eg to your admin service definition add sonata.importer.admin
tag and to configuration sonata.importer.configuration
) You can read more about service tags here.
hey @SchulzWill, do you still need any help or this can be closed?
Hello there, @kunicmarko20. Sorry for the delay in my response... Well, with autoconfigure applied like this:
sonata.admin.listing:
autoconfigure: true
autowire: true
class: Cocorico\CoreBundle\Admin\ListingAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Listings", label: "Listings" }
arguments:
- ~
- Cocorico\CoreBundle\Entity\Listing
- ~
calls:
- [ setTranslationDomain, [SonataAdminBundle]]
- [ setLocales, ["%cocorico.locales%"]]
- [ setIncludeVat, ["%cocorico.include_vat%"]]
- [ setBundlesEnabled, ["%kernel.bundles%"]]
The following error appears:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Call to a member function get() on null" at /sonata-project/admin-bundle/src/Controller/CRUDController.php line 1044 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Call to a member function get() on null at //sonata-project/admin-bundle/src/Controller/CRUDController.php:1044)"} []
This line point to:
/**
* @return Request
*/
public function getRequest()
{
return $this->container->get('request_stack')->getCurrentRequest();
}
This is weird, now the crud controller doesn't have a container instance. If I find some free time, I will try to look into it, but I can't promise anything.
Support Question
Hello there, @kunicmarko20. I have installed version 0.1.2 successfully on my application and now the button shows up on my admin page. But when I click in this button, i receive a
Uncaught PHP Exception ReflectionException: "Method importAction does not exist" at /vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php line 58 {"exception":"[object] (ReflectionException(code: 0): Method importAction does not exist at /vendor/sensio/framework-extra-bundle/EventListener/ControllerListener.php:58)"} []
My admin class looks like:
I have no AdminController defined, so I have used the https://github.com/kunicmarko20/SonataImporterBundle/tree/0.1.2#prepare-controller config I have already created a ListingCSVImportConfiguration class
src/Cocorico/CoreBundle/Importer/ListingCSVImportConfiguration.php
but couldn't link it with my Admin class and didn't find a way to do it.The ListingCSVImportConfiguration content is: