pluess / doctrine-trx-bundle
此扩展包在控制器操作中提供容器管理的交易。
dev-master
2013-02-16 10:28 UTC
Requires
- php: >=5.3.3
- doctrine/doctrine-bundle: 1.1.*
- doctrine/orm: >=2.2.3,<2.4-dev
- jms/di-extra-bundle: 1.1.*
- jms/security-extra-bundle: 1.2.*
- kriswallsmith/assetic: 1.1.*@dev
- sensio/distribution-bundle: 2.1.*
- sensio/framework-extra-bundle: 2.1.*
- sensio/generator-bundle: 2.1.*
- symfony/assetic-bundle: 2.1.*
- symfony/monolog-bundle: 2.1.*
- symfony/swiftmailer-bundle: 2.1.*
- symfony/symfony: 2.1.*
- twig/extensions: 1.0.*@dev
This package is not auto-updated.
Last update: 2024-09-28 13:09:54 UTC
README
为控制器操作添加容器管理的交易,基于doctrine的持久化。
#使用方法
要让一个操作被交易覆盖,您只需要添加以下注解
<?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.
}
}
#安装
-
将其添加到您的
composer.json
文件中,并执行composer update
"pluess/doctrine-trx-bundle": "dev-master"
-
将其添加到您的
AppKernel.php
文件中new Pluess\DoctrineTrxBundle\PluessDoctrineTrxBundle()
#致谢
有很多我从他们那里学到了很多。此扩展包的主要学习来自于
- Matthias Noback: 感谢您关于注解和事件监听器的优秀文章。这篇文章为这个扩展包打开了一扇门。
- Johannes Schmitt: 感谢您展示了如何为symfony编写独立的函数测试。
#支持如果您在使用此扩展包时遇到问题,请随时提交问题。