How to configure bundle to use Doctrine Storage
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?
There's only https://github.com/craue/CraueFormFlowBundle/pull/217#issuecomment-343450121 for now. A doc PR would be appreciated. 😏
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:
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.
@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);
// ...
}