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