|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Zikula package. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright Zikula Foundation - http://zikula.org/ |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Zikula\UsersModule\HookSubscriber; |
|
13
|
|
|
|
|
14
|
|
|
use Zikula\Bundle\HookBundle\Category\UiHooksCategory; |
|
15
|
|
|
use Zikula\Bundle\HookBundle\HookSubscriberInterface; |
|
16
|
|
|
use Zikula\Common\Translator\TranslatorInterface; |
|
17
|
|
|
|
|
18
|
|
View Code Duplication |
class UserManagementUiHooksSubscriber implements HookSubscriberInterface |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
const EDIT_DISPLAY = 'users.ui_hooks.user.display_view'; |
|
21
|
|
|
const EDIT_FORM = 'users.ui_hooks.user.form_edit'; |
|
22
|
|
|
const EDIT_VALIDATE = 'users.ui_hooks.user.validate_edit'; |
|
23
|
|
|
const EDIT_PROCESS = 'users.ui_hooks.user.process_edit'; |
|
24
|
|
|
const DELETE_FORM = 'users.ui_hooks.user.form_delete'; |
|
25
|
|
|
const DELETE_VALIDATE = 'users.ui_hooks.user.validate_delete'; |
|
26
|
|
|
const DELETE_PROCESS = 'users.ui_hooks.user.process_delete'; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var TranslatorInterface |
|
30
|
|
|
*/ |
|
31
|
|
|
private $translator; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @param TranslatorInterface $translator |
|
35
|
|
|
*/ |
|
36
|
|
|
public function __construct(TranslatorInterface $translator) |
|
37
|
|
|
{ |
|
38
|
|
|
$this->translator = $translator; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getOwner() |
|
42
|
|
|
{ |
|
43
|
|
|
return 'ZikulaUsersModule'; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function getCategory() |
|
47
|
|
|
{ |
|
48
|
|
|
return UiHooksCategory::NAME; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getTitle() |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->translator->__('User management hooks'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getEvents() |
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
|
|
UiHooksCategory::TYPE_DISPLAY_VIEW => self::EDIT_DISPLAY, |
|
60
|
|
|
UiHooksCategory::TYPE_FORM_EDIT => self::EDIT_FORM, |
|
61
|
|
|
UiHooksCategory::TYPE_VALIDATE_EDIT => self::EDIT_VALIDATE, |
|
62
|
|
|
UiHooksCategory::TYPE_PROCESS_EDIT => self::EDIT_PROCESS, |
|
63
|
|
|
UiHooksCategory::TYPE_FORM_DELETE => self::DELETE_FORM, |
|
64
|
|
|
UiHooksCategory::TYPE_VALIDATE_DELETE => self::DELETE_VALIDATE, |
|
65
|
|
|
UiHooksCategory::TYPE_PROCESS_DELETE => self::DELETE_PROCESS, |
|
66
|
|
|
]; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.