Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure bundle to use Doctrine Storage #377

Open
nestordedios opened this issue Dec 16, 2020 · 3 comments
Open

How to configure bundle to use Doctrine Storage #377

nestordedios opened this issue Dec 16, 2020 · 3 comments

Comments

@nestordedios
Copy link

Hi,

Is there any documentation/example where it explains how to configure the bundle to use the Doctrine Storage instead of the default Session Storage?

I've been searching in the repository but I couldn't find something helpful.

Do you have any recommendation?

@craue
Copy link
Owner

craue commented Dec 16, 2020

There's only #217 (comment) for now. A doc PR would be appreciated. 😏

@nestordedios
Copy link
Author

Thanks @craue !

I tried in services.yml with:

app.form.flow.user_session_storage_key:
        class: Craue\FormFlowBundle\Storage\UserSessionStorageKeyGenerator
        arguments: ['@security.token_storage', '@session']
    app.form.flow.storage.doctrine:
        class: Craue\FormFlowBundle\Storage\DoctrineStorage
        public: false
        arguments: ['@doctrine.dbal.default_connection', '@app.form.flow.user_session_storage_key']
    app.form.flow.data_manager:
        class: Craue\FormFlowBundle\Storage\DataManager
        public: false
        arguments: ['@app.form.flow.storage.doctrine']
    app.form.flow:
        class: 'App\Form\RegistrationFlow'
        calls:
        - [setDataManager, ['@app.form.flow.data_manager']]
        - [setFormFactory, ['@form.factory']]
        - [setRequestStack, ['@request_stack']]
        - [setEventDispatcher, ['@?event_dispatcher']]

but it seems the Storage being used is still SessionStorage instead of DoctrineStorage. When I dump dump($this->flow->getDataManager()->getStorage()); I get the following:

Capture

Is there something more that needs to be done after configuration? Are there any examples or docs on how to use the bundle with the Doctrine Storage?

Any help is much appreciated.

@craue
Copy link
Owner

craue commented Dec 23, 2020

@nestordedios, this config basically works for me, but make sure the flow is actually used.

-    app.form.flow:
-        class: 'App\Form\RegistrationFlow'
+    App\Form\RegistrationFlow:
// controller:
public function registrationAction(\App\Form\RegistrationFlow $flow) {
	assert($flow->getDataManager()->getStorage() instanceof \Craue\FormFlowBundle\Storage\DoctrineStorage);
	// ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants