Skip to content

[GridBundle] Impossible to create new Grid Driver #61

@Roshyo

Description

@Roshyo

Sylius version affected: 1.x (I believe all of them, from the 1.0. 1.3 for sure)

Description
In order to fetch entities from an API and then display them in a grid, we have to create at least a new Driver and register it.
The thing is, when trying to register the new Driver in SyliusGrid, this exception is thrown :

The value "your/driver" is not allowed for path "sylius_resource.drivers.1". Permissible values: "doctrine/orm", "doctrine/mongodb-odm", "doctrine/phpcr-odm"

This is due to this in Sylius\Bundle\ResourceBundle\DependencyInjection\Configuration.php

...
    /**
     * @param ArrayNodeDefinition $node
     */
    private function addDriversSection(ArrayNodeDefinition $node): void
    {
        $node
            ->children()
                ->arrayNode('drivers')
                    ->defaultValue([SyliusResourceBundle::DRIVER_DOCTRINE_ORM])
                    ->enumPrototype()->values(SyliusResourceBundle::getAvailableDrivers())->end()
                ->end()
            ->end()
        ;
    }
...

So the first step is (do not reproduce at home) to override the availableDrivers and add our (all done in vendor...)

Then, in Sylius\Bundle\ResourceBundle\AbstractResourceBundle, there is a switch/case to also mpodify and add our new value.
Next step (nearly last one) we also have to override the switch/case in Sylius\Bundle\ResourceBundle\DependencyInjection\Driver\DriverProvider

And to finish, we are warned that the XML file of our provider does not exist. So we create a new one in
Sylius/resource-bundle/Resources/config/services/integration/your/driver.xml

Steps to reproduce
Install Sylius (GridBundle at least) and try to add a new Provider

Possible Solution
Be more permissive in this bundle configuration. It is just one step away from being able to fetch data in API and display them in a grid.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions