1
|
<?php
|
2
|
|
3
|
|
4
|
namespace App\FrontModule\Components;
|
5
|
|
6
|
|
7
|
use App\Utils\DataGrid\DataGrid;
|
8
|
use App\Model\Repository\LineRepository;
|
9
|
use Ublaboo\DataGrid\Exception\DataGridException;
|
10
|
|
11
|
/**
|
12
|
* Ukázkový datagrid, bude smazán při předání
|
13
|
* - všechny možnosti použití gridu lze vidět na
|
14
|
* https://gitlab.com/Fifal/dvm/blob/21afc037e3604093197e140defc05925df0b8c28/web-project/app/components/variant/VariantGrid.php
|
15
|
*
|
16
|
* @package App\Components
|
17
|
*/
|
18
|
class ExampleGrid extends DataGrid
|
19
|
{
|
20
|
/** @var LineRepository */
|
21
|
private $lineRepository;
|
22
|
|
23
|
public function __construct(LineRepository $lineRepository)
|
24
|
{
|
25
|
$this->lineRepository = $lineRepository;
|
26
|
|
27
|
parent::__construct();
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* Abstraktní metoda, slouží k nastavení primárního klíče a nastavení datasource
|
32
|
* 1. $this->setPrimaryKey();
|
33
|
* 2. $this->setDataSource();
|
34
|
*
|
35
|
* @throws DataGridException
|
36
|
*/
|
37
|
public function init()
|
38
|
{
|
39
|
$this->setPrimaryKey(LineRepository::COLUMN_ID);
|
40
|
$this->setDataSource($this->lineRepository->findAll());
|
41
|
}
|
42
|
|
43
|
/**
|
44
|
* Definice sloupečků, akcí, vyhledávácích filtrů gridu
|
45
|
*
|
46
|
* @throws DataGridException
|
47
|
*/
|
48
|
public function define()
|
49
|
{
|
50
|
$this->addColumnNumber(LineRepository::COLUMN_ID, "ID");
|
51
|
$this->addColumnText(LineRepository::COLUMN_TRANSLITERATION, "Transliterace");
|
52
|
$this->addFilterText(LineRepository::COLUMN_TRANSLITERATION, "Transliterace");
|
53
|
|
54
|
$this->addAction(LineRepository::COLUMN_TRANSLITERATION, "Smazat");
|
55
|
}
|
56
|
}
|
57
|
|
58
|
interface IExampleGirdFactory
|
59
|
{
|
60
|
/**
|
61
|
* Funkce create je implementována již v předkovi
|
62
|
*
|
63
|
* @return ExampleGrid
|
64
|
*/
|
65
|
public function create();
|
66
|
}
|