HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/payments-gateway/vendor/doctrine/migrations/src/Event/Listeners/AutoCommitListener.php
<?php

declare(strict_types=1);

namespace Doctrine\Migrations\Event\Listeners;

use Doctrine\Common\EventSubscriber;
use Doctrine\Migrations\Event\MigrationsEventArgs;
use Doctrine\Migrations\Events;
use Doctrine\Migrations\Tools\TransactionHelper;

/**
 * Listens for `onMigrationsMigrated` and, if the connection has autocommit
 * makes sure to do the final commit to ensure changes stick around.
 *
 * @internal
 */
final class AutoCommitListener implements EventSubscriber
{
    public function onMigrationsMigrated(MigrationsEventArgs $args): void
    {
        $conn = $args->getConnection();
        $conf = $args->getMigratorConfiguration();

        if ($conf->isDryRun() || $conn->isAutoCommit()) {
            return;
        }

        TransactionHelper::commitIfInTransaction($conn);
    }

    /** {@inheritDoc} */
    public function getSubscribedEvents()
    {
        return [Events::onMigrationsMigrated];
    }
}