Projekt

Obecné

Profil

Stáhnout (1.9 KB) Statistiky
| Větev: | Tag: | Revize:
1
<?php
2

    
3
namespace App\AdminModule\Components;
4

    
5

    
6
use App\Model\Repository\SurfaceTypeRepository;
7
use App\Utils\DataGrid\DataGrid;
8
use Ublaboo\DataGrid\Exception\DataGridException;
9

    
10
class SurfaceTypeGrid extends DataGrid
11
{
12
    /** @var SurfaceTypeRepository */
13
    private $surfaceTypeRepository;
14

    
15
    /**
16
     * SurfaceTypeGrid constructor.
17
     * @param SurfaceTypeRepository $surfaceTypeRepository
18
     */
19
    public function __construct(SurfaceTypeRepository $surfaceTypeRepository)
20
    {
21
        $this->surfaceTypeRepository = $surfaceTypeRepository;
22

    
23
        parent::__construct(FALSE);
24

    
25
    }
26

    
27

    
28
    public function init()
29
    {
30
        $this->setPrimaryKey(SurfaceTypeRepository::COLUMN_ID);
31
        $this->setDataSource($this->surfaceTypeRepository->findAll()->order(SurfaceTypeRepository::COLUMN_SORTER));
32
    }
33

    
34
    /**
35
     * Definice sloupečků, akcí, vyhledávácích filtrů gridu
36
     *
37
     * @throws DataGridException
38
     */
39
    public function define()
40
    {
41
        $this->addColumnNumber(SurfaceTypeRepository::COLUMN_ID, 'ID')->setDefaultHide(TRUE);
42
        $this->addColumnText(SurfaceTypeRepository::COLUMN_SURFACE_TYPE, 'Surface Type');
43
        $this->addColumnText(SurfaceTypeRepository::COLUMN_SORTER, 'Sort Position');
44

    
45
        $this->addFilterText(SurfaceTypeRepository::COLUMN_SURFACE_TYPE, 'Surface Type');
46

    
47
        $this->addAction('edit', 'edit', 'Surface:editType', ['id' => SurfaceTypeRepository::COLUMN_ID])
48
            ->setTitle('Edit');
49

    
50
        $this->addAction('delete', 'delete', 'deleteType!', ['id' => SurfaceTypeRepository::COLUMN_ID])
51
            ->setConfirm('Do you really want to delete surface type "%s"?', SurfaceTypeRepository::COLUMN_SURFACE_TYPE)
52
            ->setTitle('Delete')
53
            ->setClass('btn btn-xs btn-danger ajax');
54

    
55
        $this->setDefaultPerPage(20);
56
    }
57
}
58

    
59
interface ISurfaceTypeGridFactory
60
{
61
    /**
62
     * @return SurfaceTypeGrid
63
     */
64
    public function create();
65
}
(1-1/3)