|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Files\Grid\Factory; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Grid\Factory\BaseFactory; |
|
8
|
|
|
use AbterPhp\Admin\Grid\Factory\GridFactory; |
|
9
|
|
|
use AbterPhp\Admin\Grid\Factory\PaginationFactory; |
|
10
|
|
|
use AbterPhp\Files\Constant\Route; |
|
11
|
|
|
use AbterPhp\Files\Domain\Entities\FileCategory as Entity; |
|
12
|
|
|
use AbterPhp\Files\Grid\Factory\Table\Header\FileCategory as HeaderFactory; |
|
13
|
|
|
use AbterPhp\Files\Grid\Factory\Table\FileCategory as TableFactory; |
|
14
|
|
|
use AbterPhp\Files\Grid\Filters\FileCategory as Filters; |
|
15
|
|
|
use AbterPhp\Framework\Constant\Html5; |
|
16
|
|
|
use AbterPhp\Framework\Grid\Action\Action; |
|
17
|
|
|
use AbterPhp\Framework\Grid\Component\Actions; |
|
18
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
|
19
|
|
|
|
|
20
|
|
|
class FileCategory extends BaseFactory |
|
21
|
|
|
{ |
|
22
|
|
|
private const GETTER_IDENTIFIER = 'getIdentifier'; |
|
23
|
|
|
private const GETTER_NAME = 'getName'; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* FileCategory constructor. |
|
27
|
|
|
* |
|
28
|
|
|
* @param UrlGenerator $urlGenerator |
|
29
|
|
|
* @param PaginationFactory $paginationFactory |
|
30
|
|
|
* @param TableFactory $tableFactory |
|
31
|
|
|
* @param GridFactory $gridFactory |
|
32
|
|
|
* @param Filters $filters |
|
33
|
|
|
*/ |
|
34
|
|
|
public function __construct( |
|
35
|
|
|
UrlGenerator $urlGenerator, |
|
36
|
|
|
PaginationFactory $paginationFactory, |
|
37
|
|
|
TableFactory $tableFactory, |
|
38
|
|
|
GridFactory $gridFactory, |
|
39
|
|
|
Filters $filters |
|
40
|
|
|
) { |
|
41
|
|
|
parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $filters); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @return array |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getGetters(): array |
|
48
|
|
|
{ |
|
49
|
|
|
return [ |
|
50
|
|
|
HeaderFactory::GROUP_NAME => static::GETTER_NAME, |
|
51
|
|
|
HeaderFactory::GROUP_IS_PUBLIC => [$this, 'getIsPublic'], |
|
52
|
|
|
HeaderFactory::GROUP_IDENTIFIER => static::GETTER_IDENTIFIER, |
|
53
|
|
|
]; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @param Entity $entity |
|
58
|
|
|
* |
|
59
|
|
|
* @return string |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getIsPublic(Entity $entity): string |
|
62
|
|
|
{ |
|
63
|
|
|
$expr = $entity->isPublic() ? 'framework:yes' : 'framework:no'; |
|
64
|
|
|
|
|
65
|
|
|
return $expr; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return Actions |
|
70
|
|
|
*/ |
|
71
|
|
|
protected function getRowActions(): Actions |
|
72
|
|
|
{ |
|
73
|
|
|
$attributeCallbacks = $this->getAttributeCallbacks(); |
|
74
|
|
|
|
|
75
|
|
|
$editAttributes = [ |
|
76
|
|
|
Html5::ATTR_HREF => Route::FILE_CATEGORIES_EDIT, |
|
77
|
|
|
]; |
|
78
|
|
|
|
|
79
|
|
|
$deleteAttributes = [ |
|
80
|
|
|
Html5::ATTR_HREF => Route::FILE_CATEGORIES_DELETE, |
|
81
|
|
|
]; |
|
82
|
|
|
|
|
83
|
|
|
$cellActions = new Actions(); |
|
84
|
|
|
$cellActions[] = new Action( |
|
85
|
|
|
static::LABEL_EDIT, |
|
86
|
|
|
$this->editIntents, |
|
87
|
|
|
$editAttributes, |
|
88
|
|
|
$attributeCallbacks, |
|
89
|
|
|
Html5::TAG_A |
|
90
|
|
|
); |
|
91
|
|
|
$cellActions[] = new Action( |
|
92
|
|
|
static::LABEL_DELETE, |
|
93
|
|
|
$this->deleteIntents, |
|
94
|
|
|
$deleteAttributes, |
|
95
|
|
|
$attributeCallbacks, |
|
96
|
|
|
Html5::TAG_A |
|
97
|
|
|
); |
|
98
|
|
|
|
|
99
|
|
|
return $cellActions; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|