Completed
Pull Request — master (#2836)
by
unknown
63:43
created

SqliteSessionInit::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace Doctrine\DBAL\Event\Listeners;
4
5
use Doctrine\DBAL\Event\ConnectionEventArgs;
6
use Doctrine\DBAL\Events;
7
use Doctrine\Common\EventSubscriber;
8
9
/**
10
 * Sqlite session init event subscriber enable foreign key constraints.
11
 */
12
class SqliteSessionInit implements EventSubscriber
13
{
14
    /**
15
     * @param \Doctrine\DBAL\Event\ConnectionEventArgs $args
16
     */
17
    public function postConnect(ConnectionEventArgs $args): void
18
    {
19
        $args->getConnection()->exec('PRAGMA foreign_keys = on');
20
    }
21
22
    /**
23
     * @return string[]
24
     */
25
    public function getSubscribedEvents(): array
26
    {
27
        return [Events::postConnect];
28
    }
29
}
30