1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Grid\Factory; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Constant\Routes; |
8
|
|
|
use AbterPhp\Admin\Grid\Factory\Table\UserApiKey as Table; |
9
|
|
|
use AbterPhp\Admin\Grid\Filters\UserApiKey as Filters; |
10
|
|
|
use AbterPhp\Framework\Constant\Html5; |
11
|
|
|
use AbterPhp\Framework\Grid\Action\Action; |
12
|
|
|
use AbterPhp\Framework\Grid\Component\Actions; |
13
|
|
|
use AbterPhp\Framework\Grid\Factory\BaseFactory; |
14
|
|
|
use AbterPhp\Framework\Grid\Factory\GridFactory; |
15
|
|
|
use AbterPhp\Framework\Grid\Factory\PaginationFactory as PaginationFactory; |
16
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
17
|
|
|
|
18
|
|
|
class UserApiKey extends BaseFactory |
19
|
|
|
{ |
20
|
|
|
const GROUP_ID = 'userapikey-id'; |
21
|
|
|
const GROUP_DESCRIPTION = 'userapikey-description'; |
22
|
|
|
|
23
|
|
|
const GETTER_ID = 'getId'; |
24
|
|
|
const GETTER_DESCRIPTION = 'getDescription'; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* User constructor. |
28
|
|
|
* |
29
|
|
|
* @param UrlGenerator $urlGenerator |
30
|
|
|
* @param PaginationFactory $paginationFactory |
31
|
|
|
* @param Table $tableFactory |
32
|
|
|
* @param GridFactory $gridFactory |
33
|
|
|
* @param Filters $filters |
34
|
|
|
*/ |
35
|
|
|
public function __construct( |
36
|
|
|
UrlGenerator $urlGenerator, |
37
|
|
|
PaginationFactory $paginationFactory, |
38
|
|
|
Table $tableFactory, |
39
|
|
|
GridFactory $gridFactory, |
40
|
|
|
Filters $filters |
41
|
|
|
) { |
42
|
|
|
parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $filters); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @return array |
47
|
|
|
*/ |
48
|
|
|
public function getGetters(): array |
49
|
|
|
{ |
50
|
|
|
return [ |
51
|
|
|
static::GROUP_ID => static::GETTER_ID, |
52
|
|
|
static::GROUP_DESCRIPTION => static::GETTER_DESCRIPTION, |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return Actions |
58
|
|
|
*/ |
59
|
|
|
protected function getRowActions(): Actions |
60
|
|
|
{ |
61
|
|
|
$attributeCallbacks = $this->getAttributeCallbacks(); |
62
|
|
|
|
63
|
|
|
$editAttributes = [ |
64
|
|
|
Html5::ATTR_HREF => [Routes::ROUTE_USER_API_EDIT], |
65
|
|
|
]; |
66
|
|
|
|
67
|
|
|
$deleteAttributes = [ |
68
|
|
|
Html5::ATTR_HREF => [Routes::ROUTE_USER_API_DELETE], |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
$cellActions = new Actions(); |
72
|
|
|
$cellActions[] = new Action( |
73
|
|
|
static::LABEL_EDIT, |
74
|
|
|
$this->editIntents, |
75
|
|
|
$editAttributes, |
76
|
|
|
$attributeCallbacks, |
77
|
|
|
Html5::TAG_A |
78
|
|
|
); |
79
|
|
|
$cellActions[] = new Action( |
80
|
|
|
static::LABEL_DELETE, |
81
|
|
|
$this->deleteIntents, |
82
|
|
|
$deleteAttributes, |
83
|
|
|
$attributeCallbacks, |
84
|
|
|
Html5::TAG_A |
85
|
|
|
); |
86
|
|
|
|
87
|
|
|
return $cellActions; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|