craue / CraueFormFlowBundle

Multi-step forms for your Symfony project.
MIT License
736 stars 118 forks source link

Add DoctrineStorage to the documentation #418

Open Ruesa18 opened 1 year ago

Ruesa18 commented 1 year ago

References: https://github.com/craue/CraueFormFlowBundle/issues/377 and https://github.com/craue/CraueFormFlowBundle/issues/377#issuecomment-747054258 in particular

This PR adds a README entry on how to configure the DoctrineStorage in a project.

RafaelKr commented 1 year ago

I would recommend to split the configuration if you are using Symfony 4.0+ to better comply with Symfony standards (https://symfony.com/doc/current/bundles/configuration.html#using-the-bundle-extension):

# config/packages/craue_form_flow.yaml
services:
    Craue\FormFlowBundle\Storage\UserSessionStorageKeyGenerator:
        arguments: [ '@security.token_storage', '@request_stack' ]
    Craue\FormFlowBundle\Storage\DoctrineStorage:
        arguments: [ '@doctrine.dbal.default_connection', '@Craue\FormFlowBundle\Storage\UserSessionStorageKeyGenerator' ]
    myCompany.form.flow.storage.doctrine_storage:
        class: 'Craue\FormFlowBundle\Storage\DataManager'
        arguments: [ '@Craue\FormFlowBundle\Storage\DoctrineStorage' ]
# config/services.yaml
services:
    myCompany.form.flow.createVehicle:
        autoconfigure: false
        calls:
            - [ setDataManager, [ '@myCompany.form.flow.storage.doctrine_storage'] ]
            - [ setFormFactory, [ '@form.factory' ] ]
            - [ setRequestStack, [ '@request_stack' ] ]
            - [ setEventDispatcher, [ '@?event_dispatcher' ] ]
Ruesa18 commented 11 months ago

Thanks @RafaelKr I added your code snippet 👍