Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DependencyInjection/SimpleThingsTransactionalExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace SimpleThings\TransactionalBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;
Expand Down
2 changes: 1 addition & 1 deletion Doctrine/ObjectTransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function setRollBackOnly()
*/
public function isCompleted()
{
return $this->isCompleted;
return $this->completed;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Doctrine/OrmTransactionStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function setRollBackOnly()
*/
public function isCompleted()
{
return $this->isCompleted;
return $this->completed;
}

/**
Expand Down Expand Up @@ -110,8 +110,8 @@ public function commit()

if ( ! $this->isRollBackOnly() && $this->manager->getConnection()->getTransactionNestingLevel() == 1) {
$this->manager->flush();
$this->manager->getConnection()->commit();
}
$this->manager->commit();

if ($this->manager->getConnection()->getTransactionNestingLevel() == 0) {
$this->completed = true;
Expand Down
5 changes: 5 additions & 0 deletions Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@
<argument type="collection" />
</service>

<service id="simple_things_transactional.form_validator" class="SimpleThings\TransactionalBundle\Transactions\Form\RollbackInvalidFormValidator" public="false">
<argument type="service" id="service_container" />
</service>

<service id="simple_things_transactional.form_extension" class="SimpleThings\TransactionalBundle\Transactions\Form\RollbackInvalidFormExtension">
<argument type="service" id="simple_things_transactional.form_validator" />
<tag name="form.type_extension" alias="form" />
</service>
</services>
Expand Down
4 changes: 2 additions & 2 deletions SimpleThingsTransactionalBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use SimpleThings\TransactionalBundle\DependencyInjection\CompilerPass\DetectConnectionsPass;
use SimpleThings\TransactionalBundle\DependencyInjection\CompilerPass\DetectConnectionPass;

class SimpleThingsTransactionalBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);

$container->addCompilerPass(new DetectConnectionsPass());
$container->addCompilerPass(new DetectConnectionPass());
}
}
12 changes: 9 additions & 3 deletions Transactions/Form/RollbackInvalidFormExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@

use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\AbstractExtension;

class RollbackInvalidFormExtension extends AbstractExtension
class RollbackInvalidFormExtension extends AbstractTypeExtension
{
private $validator;

public function __construct(RollbackInvalidFormValidator $rollbackValidator)
{
$this->validator = $rollbackValidator;
}

public function buildForm(FormBuilder $builder, array $options)
{
$builder->addValidator(new RollbackInvalidFormValidator());
$builder->addValidator($this->validator);
}

public function getExtendedType()
Expand Down
6 changes: 3 additions & 3 deletions Transactions/Form/RollbackInvalidFormValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
* to kontakt@beberlei.de so I can send you a copy immediately.
*/

namespace SimpleThingsTransactionalBundle\Transactions\Form;
namespace SimpleThings\TransactionalBundle\Transactions\Form;

use Symfony\Component\Form\FormValidatorInterface;
use Symfony\Component\Form\Form;
use Symfony\Component\Form\FormInterface;

/**
* "Missusing" the FormValidator to set transactions to rollback only when the validation failed.
Expand All @@ -39,7 +39,7 @@ public function validate(FormInterface $form)
}

$request = $this->container->get('request');
if ( ! $form->isValid( && $request->attributes->has('_transaction') ) {
if ( ! $form->isValid() && $request->attributes->has('_transaction') ) {
$request->attributes->get('_transaction')->setRollBackOnly(true);
}
}
Expand Down
2 changes: 1 addition & 1 deletion Transactions/Http/HttpTransactionsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Exceptions\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use SimpleThings\TransactionalBundle\Transactions\TransactionsRegistry;

/**
Expand Down