FriendsOfSylius / SyliusImportExportPlugin

Sylius plugin to import / export data
MIT License
118 stars 82 forks source link

Prefixed resource generates wrong format options list #249

Open armellarcier opened 3 years ago

armellarcier commented 3 years ago

In order to get an import form displayed I have type the tag with the full, prefixed resource name.

    sylius.importer.my_plugin.my_resource.xlsx:
        class: FriendsOfSylius\SyliusImportExportPlugin\Importer\ResourceImporter
        arguments:
            - "@app.factory.my_resource.spreadsheet_reader"
            - "@my_plugin.manager.my_resource"
            - "@app.processor.my_plugin.my_resource"
            - "@sylius.importer.result"
            - 100
            - false
            - false
        tags:
            - { name: sylius.importer, type: my_plugin.my_resource, format: xlsx }

But when it comes to generating the list of format options, in src/Form/ImportType.php's buildChoices method, the importer_type option is set to the request's resource name, which is not prefixed.

So ImporterRegistry::buildServiceName($importerType, 'xlsx') (in my case) returns "my_resource.xlsx" which is not registered in the ImporterRegistry since the service name is built with the "my_plugin" prefix.

I end up with only the JSON option.

cdarken commented 2 years ago

I confirm this. The cause seems to be the matching in the ImportDataController, line 49. The 'app' part is lost, the route only has the resource.