Julio Montoya 0a8495e3b5 Remove gid unset, use api_get_group_id, api_get_course_id | 9 роки тому | |
---|---|---|
.. | ||
interfaces | 9 роки тому | |
HookAdminBlock.php | 9 роки тому | |
HookCreateUser.php | 9 роки тому | |
HookEvent.php | 9 роки тому | |
HookManagement.php | 9 роки тому | |
HookNotificationContent.php | 9 роки тому | |
HookNotificationTitle.php | 9 роки тому | |
HookObserver.php | 9 роки тому | |
HookResubscribe.php | 9 роки тому | |
HookSkype.php | 9 роки тому | |
HookUpdateUser.php | 9 роки тому | |
HookWSRegistration.php | 9 роки тому | |
README.md | 9 роки тому |
Enable hooks in Chamilo to allow plugins and core to extend current features and watch for certain events.
The Hooks structure is based on the Observer pattern
The base structure is composed of 3 Interfaces
From version 1.10.x, the following Hooks (or more) exist:
Number | Directory | EventClass | ObserverInterface | Reference |
---|---|---|---|---|
1 | /main/inc/lib/usermanager.lib.php | HookCreateUser | HookCreateUserObserverInterface | UserManager::createUser() |
2 | /main/inc/lib/usermanager.lib.php | HookUpdateUser | HookUpdateUserObserverInterface | UserManager::updateUser() |
3 | /main/admin/index.php | HookAdminBlock | HookAdminBlockObserverInterface | ADMIN BLOCK |
You need to create a class extending the HookObserver
class and implement any
(or many) Hook Observer Interfaces, e.g. HookCreateUserObserverInterface
.
An observer can implement many Hook Observer Interfaces.
This was developed to allow plugins to have a unique Hook Observer class.
Don't forget to add your Hook Observer class to the autoload file (vendor/composer/autoload_classmap.php).
When installing your plugin (or other functions) you should call the attach
method from a specific Hook Observer class, e.g. HookCreateUser
class
$myHookObserver = MyHookObserver::create();
HookCreateUser::create()->attach($myHookObserver);
To detach the HookObserver, it should be detached from a specific Hook Event class
$myHookObserver = MyHookObserver::create();
HookCreateUser::create()->detach($myHookObserver);
To expand Hooks in Chamilo you should:
HookUpdateUserEventInterface
, Hook observer: HookUpdateUserObserverInterface
HookEvent
class and implementing your Hook
Event Interface