Completed
Pull Request — 3.1 (#348)
by Piotr
01:23
created

NewsDataGridBuilder   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 0
dl 0
loc 41
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildNewsDataGrid() 0 38 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