Completed
Push — master ( e16616...2d6e36 )
by
unknown
19:26 queued 03:33
created

Base   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A joinContentObjectLink() 0 9 2
A joinContentObject() 0 9 2
A joinContentObjectAttribute() 0 15 2
1
<?php
2
3
/**
4
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
5
 * @license For full copyright and license information view LICENSE file distributed with this source code.
6
 */
7
declare(strict_types=1);
8
9
namespace eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler;
10
11
use eZ\Publish\Core\Persistence\Database\SelectQuery;
12
use eZ\Publish\Core\Persistence\Legacy\URL\Query\CriterionHandler;
13
14
abstract class Base implements CriterionHandler
15
{
16
    /**
17
     * Inner join `ezurl_object_link` table if not joined yet.
18
     *
19
     * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
20
     */
21
    protected function joinContentObjectLink(SelectQuery $query): void
22
    {
23
        if (strpos($query->getQuery(), 'INNER JOIN ezurl_object_link ') === false) {
24
            $query->innerJoin(
25
                'ezurl_object_link',
26
                $query->expr->eq('ezurl.id', 'ezurl_object_link.url_id')
27
            );
28
        }
29
    }
30
31
    /**
32
     * Inner join `ezcontentobject` table if not joined yet.
33
     *
34
     * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
35
     */
36
    protected function joinContentObject(SelectQuery $query): void
37
    {
38
        if (strpos($query->getQuery(), 'INNER JOIN ezcontentobject ') === false) {
39
            $query->innerJoin(
40
                'ezcontentobject',
41
                $query->expr->eq('ezcontentobject.id', 'ezcontentobject_attribute.contentobject_id')
42
            );
43
        }
44
    }
45
46
    /**
47
     * Inner join `ezcontentobject_attribute` table if not joined yet.
48
     *
49
     * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
50
     */
51
    protected function joinContentObjectAttribute(SelectQuery $query): void
52
    {
53
        if (strpos($query->getQuery(), 'INNER JOIN ezcontentobject_attribute ') === false) {
54
            $query->innerJoin('ezcontentobject_attribute', $query->expr->lAnd(
55
                $query->expr->eq(
56
                    'ezurl_object_link.contentobject_attribute_id',
57
                    'ezcontentobject_attribute.id'
58
                ),
59
                $query->expr->eq(
60
                    'ezurl_object_link.contentobject_attribute_version',
61
                    'ezcontentobject_attribute.version'
62
                )
63
            ));
64
        }
65
    }
66
}
67