Completed
Pull Request — 3.1 (#348)
by Piotr
09:36 queued 07:40
created

NewsDataGridBuilder::buildNewsDataGrid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 38

Duplication

Lines 0
Ratio 0 %

Importance

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