$repository->transactional(
static function () use (
$repository
) {
$repository->save($entity);
//и прочее сохранение данных
}
);
public function transactional(\closure $func)
{
$db_connection = getDbConnection();
$db_connection->startTransaction();
$func();
$db_connection->commitTransaction();
}