1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Http\Controllers\Admin\Execute; |
6
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Service\Execute\UserApiKey as RepoService; |
8
|
|
|
use AbterPhp\Framework\Constant\Session; |
9
|
|
|
use AbterPhp\Framework\Http\Controllers\Admin\ExecuteAbstract; |
10
|
|
|
use AbterPhp\Framework\I18n\ITranslator; |
11
|
|
|
use AbterPhp\Framework\Session\FlashService; |
12
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
13
|
|
|
use Opulence\Sessions\ISession; |
14
|
|
|
use Psr\Log\LoggerInterface; |
15
|
|
|
|
16
|
|
|
class UserApiKey extends ExecuteAbstract |
17
|
|
|
{ |
18
|
|
|
const ENTITY_SINGULAR = 'userApiKey'; |
19
|
|
|
const ENTITY_PLURAL = 'userApiKeys'; |
20
|
|
|
|
21
|
|
|
const ENTITY_TITLE_SINGULAR = 'admin:userApiKey'; |
22
|
|
|
const ENTITY_TITLE_PLURAL = 'admin:userApiKeys'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* ApiKey constructor. |
26
|
|
|
* |
27
|
|
|
* @param FlashService $flashService |
28
|
|
|
* @param ITranslator $translator |
29
|
|
|
* @param UrlGenerator $urlGenerator |
30
|
|
|
* @param RepoService $repoService |
31
|
|
|
* @param ISession $session |
32
|
|
|
* @param LoggerInterface $logger |
33
|
|
|
*/ |
34
|
|
|
public function __construct( |
35
|
|
|
FlashService $flashService, |
36
|
|
|
ITranslator $translator, |
37
|
|
|
UrlGenerator $urlGenerator, |
38
|
|
|
RepoService $repoService, |
39
|
|
|
ISession $session, |
40
|
|
|
LoggerInterface $logger |
41
|
|
|
) { |
42
|
|
|
parent::__construct( |
43
|
|
|
$flashService, |
44
|
|
|
$translator, |
45
|
|
|
$urlGenerator, |
46
|
|
|
$repoService, |
47
|
|
|
$session, |
48
|
|
|
$logger |
49
|
|
|
); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
|
|
protected function getPostData(): array |
56
|
|
|
{ |
57
|
|
|
$postData = $this->request->getPost()->getAll(); |
58
|
|
|
|
59
|
|
|
if ($postData) { |
|
|
|
|
60
|
|
|
$postData['user_id'] = $this->session->get(Session::USER_ID); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $postData; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.