Code Duplication    Length = 44-44 lines in 2 locations

eZ/Publish/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/IsUserEnabled.php 1 location

@@ 16-59 (lines=44) @@
13
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
14
use eZ\Publish\Core\Persistence\Database\SelectQuery;
15
16
class IsUserEnabled extends CriterionHandler
17
{
18
    public function accept(Criterion $criterion): bool
19
    {
20
        return $criterion instanceof Criterion\IsUserEnabled;
21
    }
22
23
    public function handle(
24
        CriteriaConverter $converter,
25
        SelectQuery $query,
26
        Criterion $criterion,
27
        array $languageSettings
28
    ) {
29
        $subSelect = $query->subSelect();
30
        $subSelect
31
            ->select(
32
                $this->dbHandler->quoteColumn('contentobject_id', 't1')
33
            )->from(
34
                $query->alias(
35
                    $this->dbHandler->quoteTable('ezuser'),
36
                    't1'
37
                )
38
            )->leftJoin(
39
                $query->alias(
40
                    $this->dbHandler->quoteTable('ezuser_setting'),
41
                    't2'
42
                ),
43
                $query->expr->eq(
44
                    $this->dbHandler->quoteColumn('contentobject_id', 't1'),
45
                    $this->dbHandler->quoteColumn('user_id', 't2')
46
                )
47
            )->where(
48
                $query->expr->eq(
49
                    $this->dbHandler->quoteColumn('is_enabled', 't2'),
50
                    (int) reset($criterion->value)
51
                )
52
            );
53
54
        return $query->expr->in(
55
            $this->dbHandler->quoteColumn('id', 'ezcontentobject'),
56
            $subSelect
57
        );
58
    }
59
}
60

eZ/Publish/Core/Search/Legacy/Content/Common/Gateway/CriterionHandler/SectionIdentifier.php 1 location

@@ 16-59 (lines=44) @@
13
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
14
use eZ\Publish\Core\Persistence\Database\SelectQuery;
15
16
class SectionIdentifier extends CriterionHandler
17
{
18
    public function accept(Criterion $criterion): bool
19
    {
20
        return $criterion instanceof Criterion\SectionIdentifier;
21
    }
22
23
    public function handle(
24
        CriteriaConverter $converter,
25
        SelectQuery $query,
26
        Criterion $criterion,
27
        array $languageSettings
28
    ) {
29
        $subSelect = $query->subSelect();
30
        $subSelect
31
            ->select(
32
                $this->dbHandler->quoteColumn('id', 't1')
33
            )->from(
34
                $query->alias(
35
                    $this->dbHandler->quoteTable('ezcontentobject'),
36
                    't1'
37
                )
38
            )->leftJoin(
39
                $query->alias(
40
                    $this->dbHandler->quoteTable('ezsection'),
41
                    't2'
42
                ),
43
                $query->expr->eq(
44
                    $this->dbHandler->quoteColumn('section_id', 't1'),
45
                    $this->dbHandler->quoteColumn('id', 't2')
46
                )
47
            )->where(
48
                $query->expr->in(
49
                    $this->dbHandler->quoteColumn('identifier', 't2'),
50
                    $criterion->value
51
                )
52
            );
53
54
        return $query->expr->in(
55
            $this->dbHandler->quoteColumn('id', 'ezcontentobject'),
56
            $subSelect
57
        );
58
    }
59
}
60