EntityFinder.php 873 Bytes
Newer Older
1
<?php declare(strict_types=1);
2
/*
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
3
4
 * Copyright (C) 2016-2017 IRSTEA
 * All rights reserved.
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 */

namespace Irstea\PlantUmlBundle\Doctrine;

use ArrayIterator;
use Doctrine\ORM\EntityManager;
use Irstea\PlantUmlBundle\Finder\FinderInterface;

class EntityFinder implements FinderInterface
{
    /**
     * @var EntityManager
     */
    private $entityManager;

    public function __construct(EntityManager $entityManager)
    {
        $this->entityManager = $entityManager;
    }

    public function getIterator()
    {
        $classes = [];
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
28
        foreach ($this->entityManager->getMetadataFactory()->getAllMetadata() as $metadata) {
29
30
            $classes[$metadata->getName()] = $metadata->getReflectionClass();
        }
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
31

32
33
        return new ArrayIterator($classes);
    }
34
35
36
37
38

    public function toConfig(array &$conf)
    {
        $conf['type'] = 'entities';
    }
39
}