| Conditions | 1 |
| Paths | 1 |
| Total Lines | 51 |
| Code Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 25 | protected function initDataGrid(DataGridFactoryInterface $factory) |
||
| 26 | { |
||
| 27 | /* @var $datagrid \FSi\Component\DataGrid\DataGrid */ |
||
| 28 | $datagrid = $factory->createDataGrid('news'); |
||
| 29 | $datagrid->addColumn('title', 'text', array( |
||
| 30 | 'label' => 'admin.news.list.title', |
||
| 31 | 'field_mapping' => array('title', 'subtitle'), |
||
| 32 | 'value_glue' => '<br/>', |
||
| 33 | 'editable' => true |
||
| 34 | )); |
||
| 35 | $datagrid->addColumn('date', 'datetime', array( |
||
| 36 | 'label' => 'admin.news.list.date', |
||
| 37 | 'datetime_format' => 'Y-m-d', |
||
| 38 | 'editable' => true, |
||
| 39 | 'form_type' => array( |
||
| 40 | 'date' => TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date') |
||
| 41 | ), |
||
| 42 | 'form_options' => array( |
||
| 43 | 'date' => array('widget' => 'single_text') |
||
| 44 | ) |
||
| 45 | )); |
||
| 46 | $datagrid->addColumn('created_at', 'datetime', array( |
||
| 47 | 'label' => 'admin.news.list.created_at' |
||
| 48 | )); |
||
| 49 | $datagrid->addColumn('visible', 'boolean', array( |
||
| 50 | 'label' => 'admin.news.list.visible' |
||
| 51 | )); |
||
| 52 | $datagrid->addColumn('creator_email', 'text', array( |
||
| 53 | 'label' => 'admin.news.list.creator_email' |
||
| 54 | )); |
||
| 55 | $datagrid->addColumn('photo', 'fsi_image', array( |
||
| 56 | 'label' => 'admin.news.list.photo', |
||
| 57 | 'width' => 100 |
||
| 58 | )); |
||
| 59 | $datagrid->addColumn('actions', 'action', array( |
||
| 60 | 'label' => 'admin.news.list.actions', |
||
| 61 | 'field_mapping' => array('id'), |
||
| 62 | 'actions' => array( |
||
| 63 | 'edit' => array( |
||
| 64 | 'route_name' => "fsi_admin_crud_edit", |
||
| 65 | 'additional_parameters' => array('element' => $this->getId()), |
||
| 66 | 'parameters_field_mapping' => array('id' => 'id') |
||
| 67 | ), |
||
| 68 | 'display' => array( |
||
| 69 | 'element' => DisplayNews::ID |
||
| 70 | ) |
||
| 71 | ) |
||
| 72 | )); |
||
| 73 | |||
| 74 | return $datagrid; |
||
| 75 | } |
||
| 76 | |||
| 212 |