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\ApiClient as Table; |
9
|
|
|
use AbterPhp\Admin\Grid\Filters\ApiClient as Filters; |
10
|
|
|
use AbterPhp\Admin\Domain\Entities\ApiClient as Entity; |
11
|
|
|
use AbterPhp\Framework\Constant\Html5; |
12
|
|
|
use AbterPhp\Framework\Grid\Action\Action; |
13
|
|
|
use AbterPhp\Framework\Grid\Component\Actions; |
14
|
|
|
use AbterPhp\Framework\Grid\Factory\BaseFactory; |
15
|
|
|
use AbterPhp\Framework\Grid\Factory\GridFactory; |
16
|
|
|
use AbterPhp\Framework\Grid\Factory\PaginationFactory as PaginationFactory; |
17
|
|
|
use Opulence\Cryptography\Encryption\IEncrypter; |
18
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
19
|
|
|
|
20
|
|
|
class ApiClient extends BaseFactory |
21
|
|
|
{ |
22
|
|
|
const LABEL_NEW_SECRET = 'admin:newSecret'; |
23
|
|
|
|
24
|
|
|
const GROUP_ID = 'apiclient-id'; |
25
|
|
|
const GROUP_DESCRIPTION = 'apiclient-description'; |
26
|
|
|
|
27
|
|
|
const GETTER_ID = 'getId'; |
28
|
|
|
const GETTER_DESCRIPTION = 'getDescription'; |
29
|
|
|
|
30
|
|
|
/** @var IEncrypter */ |
31
|
|
|
protected $encrypter; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* User constructor. |
35
|
|
|
* |
36
|
|
|
* @param UrlGenerator $urlGenerator |
37
|
|
|
* @param PaginationFactory $paginationFactory |
38
|
|
|
* @param Table $tableFactory |
39
|
|
|
* @param GridFactory $gridFactory |
40
|
|
|
* @param Filters $filters |
41
|
|
|
* @param IEncrypter $encrypter |
42
|
|
|
*/ |
43
|
|
|
public function __construct( |
44
|
|
|
UrlGenerator $urlGenerator, |
45
|
|
|
PaginationFactory $paginationFactory, |
46
|
|
|
Table $tableFactory, |
47
|
|
|
GridFactory $gridFactory, |
48
|
|
|
Filters $filters, |
49
|
|
|
IEncrypter $encrypter |
50
|
|
|
) { |
51
|
|
|
parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $filters); |
52
|
|
|
|
53
|
|
|
$this->encrypter = $encrypter; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function getGetters(): array |
60
|
|
|
{ |
61
|
|
|
return [ |
62
|
|
|
static::GROUP_ID => static::GETTER_ID, |
63
|
|
|
static::GROUP_DESCRIPTION => static::GETTER_DESCRIPTION, |
64
|
|
|
]; |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @return Actions |
69
|
|
|
*/ |
70
|
|
|
protected function getRowActions(): Actions |
71
|
|
|
{ |
72
|
|
|
$attributeCallbacks = $this->getAttributeCallbacks(); |
73
|
|
|
|
74
|
|
|
$editAttributes = [ |
75
|
|
|
Html5::ATTR_HREF => [Routes::ROUTE_API_CLIENTS_EDIT], |
76
|
|
|
]; |
77
|
|
|
|
78
|
|
|
$deleteAttributes = [ |
79
|
|
|
Html5::ATTR_HREF => [Routes::ROUTE_API_CLIENTS_DELETE], |
80
|
|
|
]; |
81
|
|
|
|
82
|
|
|
$cellActions = new Actions(); |
83
|
|
|
$cellActions[] = new Action( |
84
|
|
|
static::LABEL_EDIT, |
85
|
|
|
$this->editIntents, |
86
|
|
|
$editAttributes, |
87
|
|
|
$attributeCallbacks, |
88
|
|
|
Html5::TAG_A |
89
|
|
|
); |
90
|
|
|
$cellActions[] = new Action( |
91
|
|
|
static::LABEL_DELETE, |
92
|
|
|
$this->deleteIntents, |
93
|
|
|
$deleteAttributes, |
94
|
|
|
$attributeCallbacks, |
95
|
|
|
Html5::TAG_A |
96
|
|
|
); |
97
|
|
|
|
98
|
|
|
return $cellActions; |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|