Code Duplication    Length = 24-25 lines in 2 locations

Admin/Traits/HandlesRelationsAdmin.php 2 locations

@@ 26-50 (lines=25) @@
23
    /**
24
     * @param FormMapper $mapper
25
     */
26
    protected function configureFormFields(FormMapper $mapper)
27
    {
28
        CoreAdmin::configureFormFields($mapper);
29
30
        // relationships that will be handled by CollectionsManager
31
        $type = 'sonata_type_collection';
32
33
        foreach ($this->formFieldDescriptions as $fieldname => $fieldDescription) {
34
            if ($fieldDescription->getType() == $type) {
35
                $this->addManagedCollections($fieldname);
36
            }
37
        }
38
39
        // relationships that will be handled by ManyToManyManager
40
        foreach ($this->formFieldDescriptions as $fieldname => $fieldDescription) {
41
            $mapping = $fieldDescription->getAssociationMapping();
42
            if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && !$mapping['isOwningSide']) {
43
                $this->addManyToManyCollections($fieldname);
44
            }
45
        }
46
47
        if (method_exists($this, 'postConfigureFormFields')) {
48
            $this->postConfigureFormFields($mapper);
49
        }
50
    }
51
52
    /**
53
     * @param ShowMapper $mapper
@@ 55-78 (lines=24) @@
52
    /**
53
     * @param ShowMapper $mapper
54
     */
55
    protected function configureShowFields(ShowMapper $mapper)
56
    {
57
        CoreAdmin::configureShowFields($mapper);
58
59
        // relationships that will be handled by CollectionsManager
60
        $types = ['sonata_type_collection', 'orm_one_to_many'];
61
        foreach ($this->showFieldDescriptions as $fieldname => $fieldDescription) {
62
            if (in_array($fieldDescription->getType(), $types)) {
63
                $this->addManagedCollections($fieldname);
64
            }
65
        }
66
67
        // relationships that will be handled by ManyToManyManager
68
        foreach ($this->showFieldDescriptions as $fieldname => $fieldDescription) {
69
            $mapping = $fieldDescription->getAssociationMapping();
70
            if ($mapping['type'] == ClassMetadataInfo::MANY_TO_MANY && !$mapping['isOwningSide']) {
71
                $this->addManyToManyCollections($fieldname);
72
            }
73
        }
74
75
        if (method_exists($this, 'postConfigureShowFields')) {
76
            $this->postConfigureShowFields($mapper);
77
        }
78
    }
79
}
80