Passed
Push — develop ( c158eb...11585d )
by Andrea
35:02
created

getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Cdf\BiCoreBundle\Subscriber;
4
5
use Doctrine\Common\EventSubscriber;
6
use Doctrine\DBAL\Event\ConnectionEventArgs;
7
use Doctrine\DBAL\Events;
8
9
class SqliteForeignKeyActivationSubscriber implements EventSubscriber
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function getSubscribedEvents()
15
    {
16
        return [
17
            Events::postConnect,
18
        ];
19
    }
20
    /**
21
     * @param ConnectionEventArgs $args
22
     * @throws \Doctrine\DBAL\DBALException
23
     */
24 40
    public function postConnect(ConnectionEventArgs $args)
25
    {
26 40
        if ('sqlite' !== strtolower($args->getDatabasePlatform()->getName())) {
27 40
            return;
28
        }
29
        $args->getConnection()->exec('PRAGMA foreign_keys = ON;');
30
    }
31
}
32