Completed
Push — 1.1 ( d166b0...e7f438 )
by Patrick
11:31 queued 07:46
created

newClassMetadataInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
use Doctrine\ORM\Mapping\ClassMetadataFactory;
7
8
class ExtensibleClassMetadataFactory extends ClassMetadataFactory
9
{
10
    /**
11
     * @var EntityManagerInterface
12
     */
13
    protected $entityManager;
14
15
    /**
16
     * Override to hold a reference to the EntityManager here as well (parent property is private).
17
     *
18
     * {@inheritdoc}
19
     */
20
    public function setEntityManager(EntityManagerInterface $em)
21
    {
22
        parent::setEntityManager($em);
23
24
        $this->entityManager = $em;
25
    }
26
27
    /**
28
     * Override to implement our custom ClassMetadata object.
29
     *
30
     * {@inheritdoc}
31
     */
32
    protected function newClassMetadataInstance($className)
33
    {
34
        return new ExtensibleClassMetadata($className, $this->entityManager->getConfiguration()->getNamingStrategy());
35
    }
36
}
37