Completed
Push — master ( 55dbed...4e3396 )
by Piotr
12s
created

NewsDataGridBuilder::buildNewsDataGrid()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 39
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 24
nc 1
nop 1
1
<?php
2
/**
3
 * (c) FSi sp. z o.o. <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace FSi\FixturesBundle\DataGrid;
10
11
use FSi\Bundle\AdminBundle\Form\TypeSolver;
12
use FSi\Component\DataGrid\DataGridInterface;
13
14
class NewsDataGridBuilder
15
{
16
    public static function buildNewsDataGrid(DataGridInterface $datagrid)
17
    {
18
        $dateType = TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date');
19
        $datagrid->addColumn('title', 'text', [
20
            'label' => 'admin.news.list.title',
21
            'field_mapping' => ['title', 'subtitle'],
22
            'value_glue' => '<br/>',
23
            'editable' => true
24
        ]);
25
26
        $datagrid->addColumn('date', 'datetime', [
27
            'label' => 'admin.news.list.date',
28
            'datetime_format' => 'Y-m-d',
29
            'editable' => true,
30
            'form_type' => ['date' => $dateType],
31
            'form_options' => [
32
                'date' => ['widget' => 'single_text']
33
            ]
34
        ]);
35
36
        $datagrid->addColumn('created_at', 'datetime', [
37
            'label' => 'admin.news.list.created_at'
38
        ]);
39
40
        $datagrid->addColumn('visible', 'boolean', [
41
            'label' => 'admin.news.list.visible'
42
        ]);
43
44
        $datagrid->addColumn('creator_email', 'text', [
45
            'label' => 'admin.news.list.creator_email'
46
        ]);
47
48
        $datagrid->addColumn('photo', 'fsi_image', [
49
            'label' => 'admin.news.list.photo',
50
            'width' => 100
51
        ]);
52
53
        return $datagrid;
54
    }
55
}
56