Completed
Push — master ( 68be21...073c54 )
by Kévin
02:41
created

DoctrineORM::getExecutorTraits()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace RulerZ\Target\DoctrineORM;
4
5
use Doctrine\ORM\QueryBuilder;
6
7
use RulerZ\Compiler\Context;
8
use RulerZ\Target\AbstractSqlTarget;
9
10
class DoctrineORM extends AbstractSqlTarget
11
{
12
    /**
13
     * @inheritDoc
14
     */
15
    public function supports($target, $mode)
16
    {
17
        return $target instanceof QueryBuilder;
18
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23
    public function createCompilationContext($target)
24
    {
25
        /** @var \Doctrine\ORM\QueryBuilder $target */
26
27
        return new Context([
28
            'root_aliases' => $target->getRootAliases(),
29
            'root_entities' => $target->getRootEntities(),
30
            'em' => $target->getEntityManager(),
31
            'joins' => $target->getDQLPart('join'),
32
        ]);
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    protected function createVisitor(Context $context)
39
    {
40
        return new DoctrineORMVisitor($context, $this->getOperators(), $this->allowStarOperator);
41
    }
42
43
    /**
44
     * @inheritDoc
45
     */
46
    protected function getExecutorTraits()
47
    {
48
        return [
49
            '\RulerZ\Executor\DoctrineORM\FilterTrait',
50
            '\RulerZ\Executor\Polyfill\FilterBasedSatisfaction',
51
        ];
52
    }
53
}
54