$ composer show --latest 'sonata-project/*'
sonata-project/admin-bundle 3.75.0 3.75.0 The missing Symfony Admin Generator
sonata-project/block-bundle 4.3.0 4.3.0 Symfony SonataBlockBundle
sonata-project/cache 2.0.1 2.0.1 Cache library
sonata-project/doctrine-extensions 1.9.1 1.9.1 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.21.0 3.21.0 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/exporter 2.3.0 2.3.0 Lightweight Exporter library
sonata-project/form-extensions 1.6.0 1.6.0 Symfony form extensions
sonata-project/intl-bundle 2.9.0 2.9.0 Symfony SonataIntlBundle
sonata-project/twig-extensions 1.4.1 1.4.1 Sonata twig extensions
$ composer show --latest 'symfony/*'
symfony/asset v4.4.11 v4.4.11 Symfony Asset Component
symfony/browser-kit v4.4.11 v4.4.11 Symfony BrowserKit Component
symfony/cache v4.4.11 v4.4.11 Symfony Cache component with PSR-6, PSR-16, and tags
symfony/cache-contracts v2.1.3 v2.1.3 Generic abstractions related to caching
symfony/config v4.4.11 v4.4.11 Symfony Config Component
symfony/console v4.4.11 v4.4.11 Symfony Console Component
symfony/css-selector v4.4.11 v4.4.11 Symfony CssSelector Component
symfony/debug v4.4.11 v4.4.11 Symfony Debug Component
symfony/debug-bundle v4.4.11 v4.4.11 Symfony DebugBundle
symfony/debug-pack v1.0.8 v1.0.8 A debug pack for Symfony projects
symfony/dependency-injection v4.4.11 v4.4.11 Symfony DependencyInjection Component
symfony/doctrine-bridge v4.4.11 v4.4.11 Symfony Doctrine Bridge
symfony/dom-crawler v4.4.11 v4.4.11 Symfony DomCrawler Component
symfony/dotenv v4.4.11 v4.4.11 Registers environment variables from a .env file
symfony/error-handler v4.4.11 v4.4.11 Symfony ErrorHandler Component
symfony/event-dispatcher v4.4.11 v4.4.11 Symfony EventDispatcher Component
symfony/event-dispatcher-contracts v1.1.9 v2.1.3 Generic abstractions related to dispatching event
symfony/expression-language v4.4.11 v4.4.11 Symfony ExpressionLanguage Component
symfony/filesystem v4.4.11 v4.4.11 Symfony Filesystem Component
symfony/finder v4.4.11 v4.4.11 Symfony Finder Component
symfony/flex v1.9.2 v1.9.2 Composer plugin for Symfony
symfony/form v4.4.11 v4.4.11 Symfony Form Component
symfony/framework-bundle v4.4.11 v4.4.11 Symfony FrameworkBundle
symfony/http-client v4.4.11 v4.4.11 Symfony HttpClient component
symfony/http-client-contracts v2.1.3 v2.1.3 Generic abstractions related to HTTP clients
symfony/http-foundation v4.4.11 v4.4.11 Symfony HttpFoundation Component
symfony/http-kernel v4.4.11 v4.4.11 Symfony HttpKernel Component
symfony/inflector v4.4.11 v4.4.11 Symfony Inflector Component
symfony/intl v4.4.11 v4.4.11 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
symfony/maker-bundle v1.21.0 v1.21.0 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
symfony/mime v4.4.11 v4.4.11 A library to manipulate MIME messages
symfony/monolog-bridge v4.4.11 v4.4.11 Symfony Monolog Bridge
symfony/monolog-bundle v3.5.0 v3.5.0 Symfony MonologBundle
symfony/options-resolver v4.4.11 v4.4.11 Symfony OptionsResolver Component
symfony/orm-pack v2.0.0 v2.0.0 A pack for the Doctrine ORM
symfony/phpunit-bridge v5.1.3 v5.1.3 Symfony PHPUnit Bridge
symfony/polyfill-intl-grapheme v1.18.1 v1.18.1 Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-icu v1.18.1 v1.18.1 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-intl-idn v1.18.1 v1.18.1 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
symfony/polyfill-intl-normalizer v1.18.1 v1.18.1 Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring v1.18.1 v1.18.1 Symfony polyfill for the Mbstring extension
symfony/polyfill-php72 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
symfony/polyfill-php73 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80 v1.18.1 v1.18.1 Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/process v4.4.11 v4.4.11 Symfony Process Component
symfony/profiler-pack v1.0.5 v1.0.5 A pack for the Symfony web profiler
symfony/property-access v4.4.11 v4.4.11 Symfony PropertyAccess Component
symfony/property-info v4.4.11 v4.4.11 Symfony Property Info Component
symfony/routing v4.4.11 v4.4.11 Symfony Routing Component
symfony/security-acl v3.1.0 v3.1.0 Symfony Security Component - ACL (Access Control List)
symfony/security-bundle v4.4.11 v4.4.11 Symfony SecurityBundle
symfony/security-core v4.4.11 v4.4.11 Symfony Security Component - Core Library
symfony/security-csrf v4.4.11 v4.4.11 Symfony Security Component - CSRF Library
symfony/security-guard v4.4.11 v4.4.11 Symfony Security Component - Guard
symfony/security-http v4.4.11 v4.4.11 Symfony Security Component - HTTP Integration
symfony/serializer v4.4.11 v4.4.11 Symfony Serializer Component
symfony/serializer-pack v1.0.3 v1.0.3 A pack for the Symfony serializer
symfony/service-contracts v2.1.3 v2.1.3 Generic abstractions related to writing services
symfony/stopwatch v4.4.11 v4.4.11 Symfony Stopwatch Component
symfony/string v5.1.3 v5.1.3 Symfony String component
symfony/swiftmailer-bundle v3.4.0 v3.4.0 Symfony SwiftmailerBundle
symfony/templating v4.4.11 v4.4.11 Symfony Templating Component
symfony/test-pack v1.0.6 v1.0.6 A pack for functional and end-to-end testing within a Symfony app
symfony/translation v4.4.11 v4.4.11 Symfony Translation Component
symfony/translation-contracts v2.1.3 v2.1.3 Generic abstractions related to translation
symfony/twig-bridge v4.4.11 v4.4.11 Symfony Twig Bridge
symfony/twig-bundle v4.4.11 v4.4.11 Symfony TwigBundle
symfony/validator v4.4.11 v4.4.11 Symfony Validator Component
symfony/var-dumper v4.4.11 v4.4.11 Symfony mechanism for exploring and dumping PHP variables
symfony/var-exporter v4.4.11 v4.4.11 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
symfony/web-link v4.4.11 v4.4.11 Symfony WebLink Component
symfony/web-profiler-bundle v4.4.11 v4.4.11 Symfony WebProfilerBundle
symfony/webpack-encore-bundle v1.7.3 v1.7.3 Integration with your Symfony app & Webpack Encore!
symfony/yaml v4.4.11 v4.4.11 Symfony Yaml Component
$ php -v
PHP 7.4.9 (cli) (built: Aug 6 2020 19:20:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies
Hello,
It seems there is an issue with the extract action.
After an update of dependencies, regardless of the chosen output format (CSV / XLS, ..), the method fail on all admins and all my updated projects witht the following error.
"Invalid "xls" format, supported formats are : ""
No particular configuration, there is as exemple the config/packages/sonata_admin.yaml file from one of my project:
sonata_admin:
title: '%sitename%'
title_logo: img/favicon.png
templates:
layout: layout.html.twig
show_mosaic_button: false
security:
handler: sonata.admin.security.handler.role
persist_filters: true
services:
sonata.admin.inspection_request:
class: App\Admin\InspectionRequestAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "inspection_requests", label: "inspection_requests", icon: '<i class="fa fa-bullhorn"></i>', on_top: true }
arguments:
- ~
- App\Entity\InspectionRequest
- ~
In the admin class, i tried to overwrite the method getExportFormats() but with OR without, same result.
I put some dump to try to understand, it seems writers are not correctly injected into the exporter instance but i can't find why.
At your disposal for more information, thanks for your time !
The Stack trace:
RuntimeException:
Invalid "xls" format, supported formats are : ""
at vendor/sonata-project/exporter/src/Exporter.php:48
at Sonata\Exporter\Exporter->getResponse('xls', 'export_inspectionrequest_2020_08_28_16_25_11.xls', object(DoctrineORMQuerySourceIterator))
(vendor/sonata-project/admin-bundle/src/Controller/CRUDController.php:942)
at Sonata\AdminBundle\Controller\CRUDController->exportAction(object(Request))
(vendor/symfony/http-kernel/HttpKernel.php:158)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/http-kernel/HttpKernel.php:80)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
(vendor/symfony/http-kernel/Kernel.php:201)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
(public/index.php:25)
Hi!
Looks like the injection works with this compiler pass: https://github.com/sonata-project/exporter/blob/6656efdf397391015313c46878f5a867f2c816e5/src/Bridge/Symfony/DependencyInjection/Compiler/ExporterCompilerPass.php#L23-L38
My guess is for some reason, there are no services tagged with sonata.exporter.writer, can you debug that compiler pass and check that?
Hi,
I understood what was going on, thank you for your referral!
Sonata\Exporter\Bridge\Symfony\Bundle\SonataExporterBundle wasn't in config/bundles.php so indeed the compiler pass wasn't executed.
Silly error on my side but I find it weird to never have needed it before. Despite using composer symfony:sync-recipes --force it was not added in the same way as Sonata\Twig\Bridge\Symfony\SonataTwigSymfonyBundle & Sonata\Doctrine\Bridge\Symfony\SonataDoctrineSymfonyBundle were recently updated.
My apologies if this is just a mistake on my end, problem solved.
Thanks for your time!
Silly error on my side but I find it weird to never have needed it before. Despite using composer symfony:sync-recipes --force it was not added in the same way as SonataTwigBridgeSymfonySonataTwigSymfonyBundle & SonataDoctrineBridgeSymfonySonataDoctrineSymfonyBundle were recently updated.
I'm not an expert in recipes, but I can't find one on https://flex.symfony.com/ , maybe we should contribute one?
Im have the idea: If no writers found throw exception with message:
It seems did you forget register bundle
Sonata\Exporter\Bridge\Symfony\Bundle\SonataExporterBundle?
It's a good idea… but you can't do it in the library, which is framework agnostic, which means you would have to first contribute something more specific than just \RuntimeException to the lib, and then catch it in the admin bundle (since it's a bundle, it means you are using Symfony).
I also ran into this, can confirm that I never needed to register the SonataExporterBundle before and that doing so fixed my issue.
I would say that it's fixed by https://github.com/sonata-project/exporter/pull/345
Most helpful comment
Hi,
I understood what was going on, thank you for your referral!
Sonata\Exporter\Bridge\Symfony\Bundle\SonataExporterBundlewasn't inconfig/bundles.phpso indeed the compiler pass wasn't executed.Silly error on my side but I find it weird to never have needed it before. Despite using
composer symfony:sync-recipes --forceit was not added in the same way asSonata\Twig\Bridge\Symfony\SonataTwigSymfonyBundle&Sonata\Doctrine\Bridge\Symfony\SonataDoctrineSymfonyBundlewere recently updated.My apologies if this is just a mistake on my end, problem solved.
Thanks for your time!