Skip to content

Adds container managed transactoins for doctrine base persistenc in controller actions.

Notifications You must be signed in to change notification settings

pluess/PluessDoctrineTrxBundle

Repository files navigation

PluessDoctrineTrxBundle

Adds container managed transactions for doctrine base persistence in controller actions.

#Usage

All you need to do to get an action covered by a transaction, is to add the annotation:

<?php

use Pluess\DoctrineTrxBundle\Annotation\DoctrineTrx as ContainerTransaction;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

use Symfony\Component\HttpFoundation\Request;

/**
 * @Route("/my_route")
 */
class MyController extends Controller
{

    /**
     * @Route("/do-something", name = "do_something")
     * @ContainerTransaction
     */
    public function applyAction(Request $request)
    {
    	$em = $this->getDoctrine()->getManager()
    	
    	// Do whatever you want to do via doctrine.
    	// The annotation makes sure it's properly covered by a transaction.
    }
    
}

#Installation

  1. Add this to your composer.json and do a composer update:

    "pluess/doctrine-trx-bundle": "dev-master"
    
  2. Add this line to your AppKernel.php:

    new Pluess\DoctrineTrxBundle\PluessDoctrineTrxBundle()
    

#Credits

There are a lot of people I'm learning from. The main learnings for this bundle are coming from

#Support Feel free to open issues if you have problems with the bundle.

About

Adds container managed transactoins for doctrine base persistenc in controller actions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages