Code Duplication    Length = 17-17 lines in 2 locations

src/Component/Translation/Repository/Doctrine/MongoDB/TranslatableRepository.php 1 location

@@ 66-82 (lines=17) @@
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getProperty($property, $root = null)
67
    {
68
        if ($this->cache === null) {
69
            $translatableFields = $this->getClassMetadata()->getFieldNames();
70
            $translationFields = $this->getDocumentManager()
71
                ->getClassMetadata($this->getClassMetadata()->getAssociationTargetClass($this->getTranslationAlias()))
72
                ->getFieldNames();
73
74
            $this->cache = array_diff($translationFields, $translatableFields);
75
        }
76
77
        if (in_array($property, $this->cache, true)) {
78
            $root = $this->getTranslationAlias();
79
        }
80
81
        return parent::getProperty($property, $root);
82
    }
83
84
    /**
85
     * @return string

src/Component/Translation/Repository/Doctrine/ORM/TranslatableRepository.php 1 location

@@ 88-104 (lines=17) @@
85
    /**
86
     * {@inheritdoc}
87
     */
88
    public function getProperty($property, $root = null)
89
    {
90
        if ($this->cache === null) {
91
            $translatableFields = $this->getClassMetadata()->getFieldNames();
92
            $translationFields = $this->getEntityManager()
93
                ->getClassMetadata($this->getClassMetadata()->getAssociationMapping('translations')['targetEntity'])
94
                ->getFieldNames();
95
96
            $this->cache = array_diff($translationFields, $translatableFields);
97
        }
98
99
        if (in_array($property, $this->cache, true)) {
100
            $root = $this->getTranslationAlias($root);
101
        }
102
103
        return parent::getProperty($property, $root);
104
    }
105
106
    /**
107
     * @param QueryBuilder|string|null $root