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

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