EntityDecorator.php 1004 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
 */

namespace Irstea\PlantUmlBundle\Doctrine;

use Irstea\PlantUmlBundle\Model\ClassVisitorInterface;
use Irstea\PlantUmlBundle\Model\NodeInterface;

/**
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
13
 * Description of EntityDecorator.
14
15
16
 */
class EntityDecorator extends AbstractDoctrineDecorator
{
17
    public function decorate(\ReflectionClass $class, NodeInterface $node, ClassVisitorInterface $visitor)
18
    {
19
        $this->withMetadata(
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
20
            function ($metadata) use ($node) {
21
22
                if ($metadata->isMappedSuperclass) {
                    $node->addStereotype('mappedSuperClass');
Guillaume Perréal's avatar
CS.    
Guillaume Perréal committed
23
                } elseif ($metadata->isEmbeddedClass) {
24
25
26
27
28
29
30
                    $node->addStereotype('embedded');
                } else {
                    $node->addStereotype('entity');
                }
            },
            $class
        );
31
    }
32
33
34
35
36

    public function toConfig(array &$conf)
    {
        $conf['decorators'][] = 'entity';
    }
37
}