temirkhan / flush-listener
Entity manager flush listener
Installs: 69
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=7.0
- doctrine/orm: ^2.5
- symfony/config: ^4.2
- symfony/dependency-injection: ^4.2
- symfony/http-kernel: ^4.2
Requires (Dev)
- phpunit/phpunit: ^6.0
- satooshi/php-coveralls: ^1.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-11-16 03:20:59 UTC
README
Automatically flushes entity manager on valid symfony response status code.
Works with symfony event dispatcher
Installation
Install bundle by composer
composer require temirkhan/flush-listener
Enable it in your app/AppKernel.php
<?php #app/AppKernel.php ... class AppKernel extends Kernel { public function registerBundles() { $bundles = [ ..., new Temirkhan\FlushListenerBundle\TemirkhanFlushListenerBundle(), ]; } ...
Usage
This is it. Now when symfony finishes handling request and return response entity manager will be flushed based on response status code.
To force flushing event dispatcher shall be used.
$dispatcher->dispatch('transaction.commit');
To prevent flushing
$dispatcher->dispatch('transaction.rollback');
This mechanism best suites postgres.