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\Property\Formatter; |
9
|
|
|
use FSi\Bundle\AdminBundle\Display\SimpleDisplay; |
10
|
|
|
use FSi\Bundle\AdminBundle\Display\Display; |
11
|
|
|
use FSi\Bundle\AdminBundle\Doctrine\Admin\DisplayElement; |
12
|
|
|
use FSi\FixturesBundle\Entity; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @Admin\Element |
16
|
|
|
*/ |
17
|
|
|
class DisplayNews extends DisplayElement |
18
|
|
|
{ |
19
|
|
|
const ID = 'news_display'; |
20
|
|
|
|
21
|
|
|
public function getId(): string |
22
|
|
|
{ |
23
|
|
|
return self::ID; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function getClassName(): string |
27
|
|
|
{ |
28
|
|
|
return Entity\News::class; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param Entity\News $object |
33
|
|
|
* @return Display |
34
|
|
|
*/ |
35
|
|
|
protected function initDisplay($object): Display |
36
|
|
|
{ |
37
|
|
|
$display = new SimpleDisplay(); |
38
|
|
|
$display->add($object->getId(), 'Identity') |
39
|
|
|
->add($object->getTitle(), 'Title') |
40
|
|
|
->add($object->getDate(), 'Date', [ |
41
|
|
|
new Formatter\EmptyValue(), |
42
|
|
|
new Formatter\DateTime('Y-m-d H:i:s') |
43
|
|
|
]) |
44
|
|
|
->add($object->isVisible(), 'Visible', [ |
45
|
|
|
new Formatter\Boolean('yes', 'no') |
46
|
|
|
]) |
47
|
|
|
->add($object->getCategories(), 'Categories', [ |
48
|
|
|
new Formatter\EmptyValue() |
49
|
|
|
]) |
50
|
|
|
->add($object->getCreatedAt(), 'Created at', [ |
51
|
|
|
new Formatter\EmptyValue(), |
52
|
|
|
new Formatter\DateTime('Y-m-d H:i:s') |
53
|
|
|
]) |
54
|
|
|
->add($object->getCreatorEmail(), 'Creator email') |
55
|
|
|
; |
56
|
|
|
|
57
|
|
|
return $display; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|