temirkhan/flush-listener

There is no license information available for the latest version (1.2.0) of this package.

Entity manager flush listener

Installs: 69

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 1

Type:symfony-bundle

1.2.0 2019-01-07 21:06 UTC

This package is auto-updated.

Last update: 2024-04-16 02:14:58 UTC


README

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.