modify plugin name
This commit is contained in:
@@ -15,8 +15,12 @@ use Database\Affair\Rollback;
|
|||||||
use Database\Traits\QueryTrait;
|
use Database\Traits\QueryTrait;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Kiri\Abstracts\Config;
|
use Kiri\Abstracts\Config;
|
||||||
|
use Kiri\Context;
|
||||||
use Kiri\Events\EventDispatch;
|
use Kiri\Events\EventDispatch;
|
||||||
use Kiri\Exception\ConfigException;
|
use Kiri\Exception\ConfigException;
|
||||||
|
use Psr\Container\ContainerExceptionInterface;
|
||||||
|
use Psr\Container\NotFoundExceptionInterface;
|
||||||
|
use ReflectionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Db
|
* Class Db
|
||||||
@@ -32,47 +36,49 @@ class Db implements ISqlBuilder
|
|||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function transactionsActive(): bool
|
public static function inTransactionsActive(): bool
|
||||||
{
|
{
|
||||||
return static::$_inTransaction === true;
|
return Context::hasContext('transactions::status') && Context::getContext('transactions::status') === true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function beginTransaction()
|
public static function beginTransaction()
|
||||||
{
|
{
|
||||||
if (!static::transactionsActive()) {
|
Context::setContext('transactions::status', true);
|
||||||
$event = \Kiri::getDi()->get(EventDispatch::class);
|
|
||||||
$event->dispatch(new BeginTransaction());
|
$event = \Kiri::getDi()->get(EventDispatch::class);
|
||||||
}
|
$event->dispatch(new BeginTransaction());
|
||||||
static::$_inTransaction = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function commit()
|
public static function commit()
|
||||||
{
|
{
|
||||||
if (static::transactionsActive()) {
|
$event = \Kiri::getDi()->get(EventDispatch::class);
|
||||||
$event = \Kiri::getDi()->get(EventDispatch::class);
|
$event->dispatch(new Commit());
|
||||||
$event->dispatch(new Commit());
|
Context::remove('transactions::status');
|
||||||
}
|
|
||||||
static::$_inTransaction = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @return void
|
||||||
|
* @throws ContainerExceptionInterface
|
||||||
|
* @throws NotFoundExceptionInterface
|
||||||
|
* @throws ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function rollback()
|
public static function rollback()
|
||||||
{
|
{
|
||||||
if (static::transactionsActive()) {
|
$event = \Kiri::getDi()->get(EventDispatch::class);
|
||||||
$event = \Kiri::getDi()->get(EventDispatch::class);
|
$event->dispatch(new Rollback());
|
||||||
$event->dispatch(new Rollback());
|
Context::remove('transactions::status');
|
||||||
}
|
|
||||||
static::$_inTransaction = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user