| 1 | <?php |
||
| 11 | class CustomNews extends CRUDElement |
||
| 12 | { |
||
| 13 | public function getId() |
||
| 14 | { |
||
| 15 | return 'custom_news'; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getClassName() |
||
| 19 | { |
||
| 20 | return 'FSi\FixturesBundle\Entity\News'; |
||
| 21 | } |
||
| 22 | |||
| 23 | protected function initDataGrid(DataGridFactoryInterface $factory) |
||
| 24 | { |
||
| 25 | /* @var $datagrid \FSi\Component\DataGrid\DataGrid */ |
||
| 26 | $datagrid = $factory->createDataGrid('custom_news'); |
||
| 27 | |||
| 28 | return $datagrid; |
||
| 29 | } |
||
| 30 | |||
| 31 | protected function initDataSource(DataSourceFactoryInterface $factory) |
||
| 32 | { |
||
| 33 | /* @var $datasource \FSi\Component\DataSource\DataSource */ |
||
| 34 | $datasource = $factory->createDataSource('doctrine', ['entity' => $this->getClassName()], 'custom_news'); |
||
| 35 | |||
| 36 | $datasource->addField('title', 'text', 'eq', ['form_filter' => false]); |
||
| 37 | |||
| 38 | return $datasource; |
||
| 39 | } |
||
| 40 | |||
| 41 | protected function initForm(FormFactoryInterface $factory, $data = null) |
||
| 42 | { |
||
| 43 | $builder = $factory->createNamedBuilder( |
||
| 44 | 'news', |
||
| 45 | TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\FormType', 'form'), |
||
| 46 | $data, |
||
| 47 | ['data_class' => $this->getClassName()] |
||
| 48 | ); |
||
| 49 | |||
| 50 | return $builder->getForm(); |
||
| 51 | } |
||
| 52 | } |
||
| 53 |