Completed
Pull Request — 3.1 (#348)
by Piotr
07:35
created

CategoryNewsDisplay   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 44
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A getParentId() 0 4 1
A getClassName() 0 4 1
A initDisplay() 0 20 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FSi\FixturesBundle\Admin;
6
7
use FSi\Bundle\AdminBundle\Annotation as Admin;
8
use FSi\Bundle\AdminBundle\Display\Display;
9
use FSi\Bundle\AdminBundle\Display\PropertyAccessDisplay;
10
use FSi\Bundle\AdminBundle\Display\Property\Formatter;
11
use FSi\Bundle\AdminBundle\Doctrine\Admin\DependentDisplayElement;
12
use FSi\FixturesBundle\Entity;
13
14
/**
15
 * @Admin\Element
16
 */
17
class CategoryNewsDisplay extends DependentDisplayElement
18
{
19
    const ID = 'category_news_display';
20
21
    public function getId(): string
22
    {
23
        return self::ID;
24
    }
25
26
    public function getParentId(): string
27
    {
28
        return 'category';
29
    }
30
31
    public function getClassName(): string
32
    {
33
        return Entity\News::class;
34
    }
35
36
    /**
37
     * @param mixed $object
38
     * @return Display
39
     */
40
    protected function initDisplay($object): Display
41
    {
42
        $display = new PropertyAccessDisplay($object);
43
        $display->add('id', 'Identity')
44
            ->add('title')
45
            ->add('date', null, [
46
                new Formatter\EmptyValue(),
47
                new Formatter\DateTime('Y-m-d H:i:s')
48
            ])
49
            ->add('visible', 'Visible', [
50
                new Formatter\Boolean('yes', 'no')
51
            ])
52
            ->add('createdAt', null, [
53
                new Formatter\EmptyValue(),
54
                new Formatter\DateTime('Y-m-d H:i:s')
55
            ])
56
            ->add('creatorEmail');
57
58
        return $display;
59
    }
60
}
61