|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Sylius package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Paweł Jędrzejewski |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
declare(strict_types=1); |
|
13
|
|
|
|
|
14
|
|
|
namespace Sylius\Bundle\GridBundle\Templating\Helper; |
|
15
|
|
|
|
|
16
|
|
|
use Sylius\Component\Grid\Definition\Action; |
|
17
|
|
|
use Sylius\Component\Grid\Definition\Field; |
|
18
|
|
|
use Sylius\Component\Grid\Definition\Filter; |
|
19
|
|
|
use Sylius\Component\Grid\Renderer\GridRendererInterface; |
|
20
|
|
|
use Sylius\Component\Grid\View\GridView; |
|
21
|
|
|
use Symfony\Component\Templating\Helper\Helper; |
|
22
|
|
|
|
|
23
|
|
|
class GridHelper extends Helper |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var GridRendererInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
private $gridRenderer; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @param GridRendererInterface $gridRenderer |
|
32
|
|
|
*/ |
|
33
|
|
|
public function __construct(GridRendererInterface $gridRenderer) |
|
34
|
|
|
{ |
|
35
|
|
|
$this->gridRenderer = $gridRenderer; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param GridView $gridView |
|
40
|
|
|
* @param string|null $template |
|
41
|
|
|
* |
|
42
|
|
|
* @return mixed |
|
43
|
|
|
*/ |
|
44
|
|
|
public function renderGrid(GridView $gridView, ?string $template = null) |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->gridRenderer->render($gridView, $template); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param GridView $gridView |
|
51
|
|
|
* @param Field $field |
|
52
|
|
|
* @param mixed $data |
|
53
|
|
|
* |
|
54
|
|
|
* @return mixed |
|
55
|
|
|
*/ |
|
56
|
|
|
public function renderField(GridView $gridView, Field $field, $data) |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->gridRenderer->renderField($gridView, $field, $data); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @param GridView $gridView |
|
63
|
|
|
* @param Action $action |
|
64
|
|
|
* @param mixed|null $data |
|
65
|
|
|
* |
|
66
|
|
|
* @return mixed |
|
67
|
|
|
*/ |
|
68
|
|
|
public function renderAction(GridView $gridView, Action $action, $data = null) |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->gridRenderer->renderAction($gridView, $action, $data); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param GridView $gridView |
|
75
|
|
|
* @param Filter $filter |
|
76
|
|
|
* |
|
77
|
|
|
* @return mixed |
|
78
|
|
|
*/ |
|
79
|
|
|
public function renderFilter(GridView $gridView, Filter $filter) |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->gridRenderer->renderFilter($gridView, $filter); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getName(): string |
|
88
|
|
|
{ |
|
89
|
|
|
return 'sylius_grid'; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|