Code Duplication    Length = 26-26 lines in 2 locations

Entity/Repository/BlockRepository.php 1 location

@@ 31-56 (lines=26) @@
28
            ->getOneOrNullResult();
29
    }
30
31
    public function findTranslation(Block $block, $locale)
32
    {
33
        $source = null;
34
35
        // We are checking if the node is the translation provider or translated
36
        // from an other node
37
        if ($block->getTranslationSource() !== null) {
38
            $source = $block->getTranslationSource();
39
            if ($source->getLocale() == $locale) {
40
                return $source;
41
            }
42
        } else {
43
            $source = $block;
44
        }
45
46
        return $this->createQueryBuilder('n')
47
            ->addSelect('n')
48
            ->andWhere('n.translationSource = :source')
49
            ->andWhere('n.locale = :locale')
50
            ->setParameters([
51
                'source' => $source,
52
                'locale' => $locale,
53
            ])
54
            ->getQuery()
55
            ->getOneOrNullResult();
56
    }
57
}
58

Entity/Repository/NodeRepository.php 1 location

@@ 58-83 (lines=26) @@
55
            ->getOneOrNullResult();
56
    }
57
58
    public function findTranslation(Node $node, $locale)
59
    {
60
        $nodeSource = null;
61
62
        // We are checking if the node is the translation provider or translated
63
        // from an other node
64
        if ($node->getTranslationSource() !== null) {
65
            $nodeSource = $node->getTranslationSource();
66
            if ($nodeSource->getLocale() == $locale) {
67
                return $nodeSource;
68
            }
69
        } else {
70
            $nodeSource = $node;
71
        }
72
73
        return $this->createQueryBuilder('n')
74
                    ->addSelect('n')
75
                    ->andWhere('n.translationSource = :source')
76
                    ->andWhere('n.locale = :locale')
77
                    ->setParameters([
78
                        'source' => $nodeSource,
79
                        'locale' => $locale,
80
                    ])
81
                    ->getQuery()
82
                    ->getOneOrNullResult();
83
    }
84
}
85