Skip to content

TemirkhanN/flush-listener

Repository files navigation

temirkhan/flush-listener

Automatically flushes entity manager on valid symfony response status code.

Build Status Coverage Status

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.

About

flushes entity manager on valid symfony response

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages