|
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 RegistrationUiHooksSubscriber implements HookSubscriberInterface |
|
|
|
|
|
|
19
|
|
|
{ |
|
20
|
|
|
const REGISTRATION_DISPLAY = 'users.ui_hooks.registration.display_view'; |
|
21
|
|
|
const REGISTRATION_FORM = 'users.ui_hooks.registration.form_edit'; |
|
22
|
|
|
const REGISTRATION_VALIDATE = 'users.ui_hooks.registration.validate_edit'; |
|
23
|
|
|
const REGISTRATION_PROCESS = 'users.ui_hooks.registration.process_edit'; |
|
24
|
|
|
const REGISTRATION_DELETE_FORM = 'users.ui_hooks.registration.form_delete'; |
|
25
|
|
|
const REGISTRATION_DELETE_VALIDATE = 'users.ui_hooks.registration.validate_delete'; |
|
26
|
|
|
const REGISTRATION_DELETE_PROCESS = 'users.ui_hooks.registration.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->__('Registration management hooks'); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getEvents() |
|
57
|
|
|
{ |
|
58
|
|
|
return [ |
|
59
|
|
|
UiHooksCategory::TYPE_DISPLAY_VIEW => self::REGISTRATION_DISPLAY, |
|
60
|
|
|
UiHooksCategory::TYPE_FORM_EDIT => self::REGISTRATION_FORM, |
|
61
|
|
|
UiHooksCategory::TYPE_VALIDATE_EDIT => self::REGISTRATION_VALIDATE, |
|
62
|
|
|
UiHooksCategory::TYPE_PROCESS_EDIT => self::REGISTRATION_PROCESS, |
|
63
|
|
|
UiHooksCategory::TYPE_FORM_DELETE => self::REGISTRATION_DELETE_FORM, |
|
64
|
|
|
UiHooksCategory::TYPE_VALIDATE_DELETE => self::REGISTRATION_DELETE_VALIDATE, |
|
65
|
|
|
UiHooksCategory::TYPE_PROCESS_DELETE => self::REGISTRATION_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.