1 | <?php |
||
14 | class News extends CRUDElement |
||
15 | { |
||
16 | public function getId() |
||
17 | { |
||
18 | return 'news'; |
||
19 | } |
||
20 | |||
21 | public function getClassName() |
||
22 | { |
||
23 | return 'FSi\FixturesBundle\Entity\News'; |
||
24 | } |
||
25 | |||
26 | protected function initDataGrid(DataGridFactoryInterface $factory) |
||
27 | { |
||
28 | /* @var $datagrid \FSi\Component\DataGrid\DataGrid */ |
||
29 | $datagrid = $factory->createDataGrid('news'); |
||
30 | |||
31 | NewsDataGridBuilder::buildNewsDataGrid($datagrid); |
||
32 | |||
33 | $datagrid->addColumn('actions', 'action', [ |
||
34 | 'label' => 'admin.news.list.actions', |
||
35 | 'field_mapping' => ['id'], |
||
36 | 'actions' => [ |
||
37 | 'edit' => [ |
||
38 | 'route_name' => "fsi_admin_crud_edit", |
||
39 | 'additional_parameters' => ['element' => $datagrid->getName()], |
||
40 | 'parameters_field_mapping' => ['id' => 'id'] |
||
41 | ], |
||
42 | 'display' => ['element' => DisplayNews::ID] |
||
43 | ] |
||
44 | ]); |
||
45 | |||
46 | return $datagrid; |
||
47 | } |
||
48 | |||
49 | protected function initDataSource(DataSourceFactoryInterface $factory) |
||
50 | { |
||
51 | /* @var $datasource \FSi\Component\DataSource\DataSource */ |
||
52 | $datasource = $factory->createDataSource('doctrine', ['entity' => $this->getClassName()], 'news'); |
||
53 | |||
54 | NewsDataSourceBuilder::buildNewsDataSource($datasource); |
||
55 | |||
56 | return $datasource; |
||
57 | } |
||
58 | |||
59 | protected function initForm(FormFactoryInterface $factory, $data = null) |
||
60 | { |
||
61 | return $factory->createNamed( |
||
62 | 'news', |
||
63 | TypeSolver::getFormType('FSi\FixturesBundle\Form\NewsType', new NewsType()), |
||
64 | $data |
||
65 | ); |
||
66 | } |
||
67 | } |
||
68 |