|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Admin\Http\Controllers\Admin\Form; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Domain\Entities\UserGroup as Entity; |
|
8
|
|
|
use AbterPhp\Admin\Form\Factory\UserGroup as FormFactory; |
|
9
|
|
|
use AbterPhp\Admin\Http\Controllers\Admin\FormAbstract; |
|
10
|
|
|
use AbterPhp\Admin\Orm\UserGroupRepo as Repo; |
|
11
|
|
|
use AbterPhp\Framework\Assets\AssetManager; |
|
12
|
|
|
use AbterPhp\Framework\Domain\Entities\IStringerEntity; |
|
13
|
|
|
use AbterPhp\Framework\I18n\ITranslator; |
|
14
|
|
|
use AbterPhp\Framework\Session\FlashService; |
|
15
|
|
|
use Opulence\Events\Dispatchers\IEventDispatcher; |
|
16
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
|
17
|
|
|
use Opulence\Sessions\ISession; |
|
18
|
|
|
use Psr\Log\LoggerInterface; |
|
19
|
|
|
|
|
20
|
|
|
class UserGroup extends FormAbstract |
|
21
|
|
|
{ |
|
22
|
|
|
const ENTITY_PLURAL = 'userGroups'; |
|
23
|
|
|
const ENTITY_SINGULAR = 'userGroup'; |
|
24
|
|
|
|
|
25
|
|
|
const ENTITY_TITLE_SINGULAR = 'admin:userGroup'; |
|
26
|
|
|
const ENTITY_TITLE_PLURAL = 'admin:userGroups'; |
|
27
|
|
|
|
|
28
|
|
|
const ROUTING_PATH = 'user-groups'; |
|
29
|
|
|
|
|
30
|
|
|
/** @var string */ |
|
31
|
|
|
protected $resource = 'user_groups'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* UserGroup constructor. |
|
35
|
|
|
* |
|
36
|
|
|
* @param FlashService $flashService |
|
37
|
|
|
* @param ITranslator $translator |
|
38
|
|
|
* @param UrlGenerator $urlGenerator |
|
39
|
|
|
* @param LoggerInterface $logger |
|
40
|
|
|
* @param Repo $repo |
|
41
|
|
|
* @param ISession $session |
|
42
|
|
|
* @param FormFactory $formFactory |
|
43
|
|
|
* @param IEventDispatcher $eventDispatcher |
|
44
|
|
|
* @param AssetManager $assetManager |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct( |
|
47
|
|
|
FlashService $flashService, |
|
48
|
|
|
ITranslator $translator, |
|
49
|
|
|
UrlGenerator $urlGenerator, |
|
50
|
|
|
LoggerInterface $logger, |
|
51
|
|
|
Repo $repo, |
|
52
|
|
|
ISession $session, |
|
53
|
|
|
FormFactory $formFactory, |
|
54
|
|
|
IEventDispatcher $eventDispatcher, |
|
55
|
|
|
AssetManager $assetManager |
|
56
|
|
|
) { |
|
57
|
|
|
parent::__construct( |
|
58
|
|
|
$flashService, |
|
59
|
|
|
$translator, |
|
60
|
|
|
$urlGenerator, |
|
61
|
|
|
$logger, |
|
62
|
|
|
$repo, |
|
63
|
|
|
$session, |
|
64
|
|
|
$formFactory, |
|
65
|
|
|
$eventDispatcher |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$this->assetManager = $assetManager; |
|
|
|
|
|
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @param string $entityId |
|
73
|
|
|
* |
|
74
|
|
|
* @return Entity |
|
75
|
|
|
*/ |
|
76
|
|
|
protected function createEntity(string $entityId): IStringerEntity |
|
77
|
|
|
{ |
|
78
|
|
|
return new Entity($entityId, '', ''); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param IStringerEntity|null $entity |
|
83
|
|
|
* |
|
84
|
|
|
* @throws \League\Flysystem\FileNotFoundException |
|
85
|
|
|
*/ |
|
86
|
|
|
protected function addCustomAssets(?IStringerEntity $entity = null) |
|
87
|
|
|
{ |
|
88
|
|
|
parent::addCustomAssets($entity); |
|
89
|
|
|
|
|
90
|
|
|
if (!($entity instanceof Entity)) { |
|
91
|
|
|
return; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
$footer = $this->getResourceName(static::RESOURCE_FOOTER); |
|
95
|
|
|
$this->assetManager->addJs($footer, '/admin-assets/js/semi-auto.js'); |
|
96
|
|
|
} |
|
97
|
|
|
} |
|
98
|
|
|
|