Code Duplication    Length = 24-25 lines in 2 locations

Admin/Traits/HandlesRelationsAdmin.php 2 locations

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