Code Duplication    Length = 14-15 lines in 2 locations

Bundle/AnalyticsBundle/EventSubscriber/BrowseEventSubscriber.php 1 location

@@ 48-61 (lines=14) @@
45
        $metadatas = $eventArgs->getClassMetadata();
46
47
        //Add author relation on BrowseEvent
48
        if ($this->userClass && $metadatas->name === 'Victoire\Bundle\AnalyticsBundle\Entity\BrowseEvent') {
49
            $metadatas->mapManyToOne([
50
                'fieldName'    => 'author',
51
                'targetEntity' => $this->userClass,
52
                'cascade'      => ['persist'],
53
                'joinColumns'  => [
54
                    [
55
                        'name'                 => 'author_id',
56
                        'referencedColumnName' => 'id',
57
                        'onDelete'             => 'SET NULL',
58
                    ],
59
                ],
60
            ]);
61
        }
62
    }
63
}
64

Bundle/PageBundle/EventSubscriber/PageSubscriber.php 1 location

@@ 104-118 (lines=15) @@
101
        $metaBuilder = new ClassMetadataBuilder($metadata);
102
103
        //Add author relation on view
104
        if ($this->userClass && $metadata->name === 'Victoire\Bundle\CoreBundle\Entity\View') {
105
            $metadata->mapManyToOne([
106
                'fieldName'    => 'author',
107
                'targetEntity' => $this->userClass,
108
                'cascade'      => ['persist'],
109
                'inversedBy'   => 'pages',
110
                'joinColumns'  => [
111
                    [
112
                        'name'                 => 'author_id',
113
                        'referencedColumnName' => 'id',
114
                        'onDelete'             => 'SET NULL',
115
                    ],
116
                ],
117
            ]);
118
        }
119
120
        // if $pages property exists, add the inversed side on User
121
        if ($metadata->name === $this->userClass && property_exists($this->userClass, 'pages')) {