|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace FSi\FixturesBundle\Admin; |
|
4
|
|
|
|
|
5
|
|
|
use FSi\Bundle\AdminBundle\Doctrine\Admin\ListElement; |
|
6
|
|
|
use FSi\Bundle\AdminBundle\Form\TypeSolver; |
|
7
|
|
|
use FSi\Component\DataGrid\DataGridFactoryInterface; |
|
8
|
|
|
use FSi\Component\DataSource\DataSourceFactoryInterface; |
|
9
|
|
|
|
|
10
|
|
|
class Subscriber extends ListElement |
|
11
|
|
|
{ |
|
12
|
|
|
public function getId() |
|
13
|
|
|
{ |
|
14
|
|
|
return 'subscriber'; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function getClassName() |
|
18
|
|
|
{ |
|
19
|
|
|
return 'FSi\FixturesBundle\Entity\Subscriber'; |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
protected function initDataGrid(DataGridFactoryInterface $factory) |
|
23
|
|
|
{ |
|
24
|
|
|
/* @var $datagrid \FSi\Component\DataGrid\DataGrid */ |
|
25
|
|
|
$datagrid = $factory->createDataGrid('subscriber'); |
|
26
|
|
|
$datagrid->addColumn('batch', 'batch', [ |
|
27
|
|
|
'actions' => [ |
|
28
|
|
|
[ |
|
29
|
|
|
'element' => 'subscriber_delete', |
|
30
|
|
|
'label' => 'crud.list.batch.delete' |
|
31
|
|
|
] |
|
32
|
|
|
] |
|
33
|
|
|
]); |
|
34
|
|
|
$datagrid->addColumn('email', 'text', [ |
|
35
|
|
|
'label' => 'admin.subscriber.list.email', |
|
36
|
|
|
'editable' => true, |
|
37
|
|
|
'form_type' => [ |
|
38
|
|
|
'email' => TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\EmailType', 'email') |
|
39
|
|
|
] |
|
40
|
|
|
]); |
|
41
|
|
|
$datagrid->addColumn('active', 'boolean', [ |
|
42
|
|
|
'label' => 'admin.subscriber.list.active' |
|
43
|
|
|
]); |
|
44
|
|
|
$datagrid->addColumn('created_at', 'datetime', [ |
|
45
|
|
|
'label' => 'admin.subscriber.list.created_at' |
|
46
|
|
|
]); |
|
47
|
|
|
$datagrid->addColumn('actions', 'action', [ |
|
48
|
|
|
'label' => 'admin.subscriber.list.actions', |
|
49
|
|
|
'field_mapping' => ['id'], |
|
50
|
|
|
'actions' => ['edit' => ['element' => 'subscriber_form']] |
|
51
|
|
|
]); |
|
52
|
|
|
|
|
53
|
|
|
return $datagrid; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
protected function initDataSource(DataSourceFactoryInterface $factory) |
|
57
|
|
|
{ |
|
58
|
|
|
/* @var $datasource \FSi\Component\DataSource\DataSource */ |
|
59
|
|
|
$datasource = $factory->createDataSource('doctrine', ['entity' => $this->getClassName()], 'subscriber'); |
|
60
|
|
|
$datasource->addField('email', 'text', 'like', [ |
|
61
|
|
|
'sortable' => true, |
|
62
|
|
|
'form_options' => [ |
|
63
|
|
|
'label' => 'admin.subscriber.list.email', |
|
64
|
|
|
] |
|
65
|
|
|
]); |
|
66
|
|
|
$datasource->addField('created_at', 'date', 'between', [ |
|
67
|
|
|
'field' => 'createdAt', |
|
68
|
|
|
'sortable' => true, |
|
69
|
|
|
'form_from_options' => [ |
|
70
|
|
|
'widget' => 'single_text', |
|
71
|
|
|
'label' => 'admin.subscriber.list.created_at_from', |
|
72
|
|
|
], |
|
73
|
|
|
'form_to_options' => [ |
|
74
|
|
|
'widget' => 'single_text', |
|
75
|
|
|
'label' => 'admin.subscriber.list.created_at_to', |
|
76
|
|
|
] |
|
77
|
|
|
]); |
|
78
|
|
|
$datasource->addField('active', 'boolean', 'eq', [ |
|
79
|
|
|
'sortable' => false, |
|
80
|
|
|
'form_options' => [ |
|
81
|
|
|
'label' => 'admin.subscriber.list.active', |
|
82
|
|
|
] |
|
83
|
|
|
]); |
|
84
|
|
|
|
|
85
|
|
|
$datasource->setMaxResults(10); |
|
86
|
|
|
|
|
87
|
|
|
return $datasource; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|