]> BookStack Code Mirror - bookstack/blob - app/Theming/ThemeEvents.php
Merge pull request #3556 from GongMingCai/development
[bookstack] / app / Theming / ThemeEvents.php
1 <?php
2
3 namespace BookStack\Theming;
4
5 /**
6  * The ThemeEvents used within BookStack.
7  *
8  * This file details the events that BookStack may fire via the custom
9  * theme system, including event names, parameters and expected return types.
10  *
11  * This system is regarded as semi-stable.
12  * We'll look to fix issues with it or migrate old event types but
13  * events and their signatures may change in new versions of BookStack.
14  * We'd advise testing any usage of these events upon upgrade.
15  */
16 class ThemeEvents
17 {
18     /**
19      * Activity logged event.
20      * Runs right after an activity is logged by bookstack.
21      * These are the activities that can be seen in the audit log area of BookStack.
22      * Activity types can be seen listed in the \BookStack\Actions\ActivityType class.
23      * The provided $detail can be a string or a loggable type of model. You should check
24      * the type before making use of this parameter.
25      *
26      * @param string                                $type
27      * @param string|\BookStack\Interfaces\Loggable $detail
28      */
29     const ACTIVITY_LOGGED = 'activity_logged';
30
31     /**
32      * Application boot-up.
33      * After main services are registered.
34      *
35      * @param \BookStack\Application $app
36      */
37     const APP_BOOT = 'app_boot';
38
39     /**
40      * Auth login event.
41      * Runs right after a user is logged-in to the application by any authentication
42      * system as a standard app user. This includes a user becoming logged in
43      * after registration. This is not emitted upon API usage.
44      *
45      * @param string               $authSystem
46      * @param \BookStack\Auth\User $user
47      */
48     const AUTH_LOGIN = 'auth_login';
49
50     /**
51      * Auth register event.
52      * Runs right after a user is newly registered to the application by any authentication
53      * system as a standard app user. This includes auto-registration systems used
54      * by LDAP, SAML and social systems. It only includes self-registrations.
55      *
56      * @param string               $authSystem
57      * @param \BookStack\Auth\User $user
58      */
59     const AUTH_REGISTER = 'auth_register';
60
61     /**
62      * Commonmark environment configure.
63      * Provides the commonmark library environment for customization
64      * before it's used to render markdown content.
65      * If the listener returns a non-null value, that will be used as an environment instead.
66      *
67      * @param \League\CommonMark\ConfigurableEnvironmentInterface $environment
68      * @returns \League\CommonMark\ConfigurableEnvironmentInterface|null
69      */
70     const COMMONMARK_ENVIRONMENT_CONFIGURE = 'commonmark_environment_configure';
71
72     /**
73      * Web before middleware action.
74      * Runs before the request is handled but after all other middleware apart from those
75      * that depend on the current session user (Localization for example).
76      * Provides the original request to use.
77      * Return values, if provided, will be used as a new response to use.
78      *
79      * @param \Illuminate\Http\Request $request
80      * @returns \Illuminate\Http\Response|null
81      */
82     const WEB_MIDDLEWARE_BEFORE = 'web_middleware_before';
83
84     /**
85      * Web after middleware action.
86      * Runs after the request is handled but before the response is sent.
87      * Provides both the original request and the currently resolved response.
88      * Return values, if provided, will be used as a new response to use.
89      *
90      * @param \Illuminate\Http\Request                                                       $request
91      * @param \Illuminate\Http\Response|\Symfony\Component\HttpFoundation\BinaryFileResponse $response
92      * @returns \Illuminate\Http\Response|null
93      */
94     const WEB_MIDDLEWARE_AFTER = 'web_middleware_after';
95
96     /**
97      * Webhook call before event.
98      * Runs before a webhook endpoint is called. Allows for customization
99      * of the data format & content within the webhook POST request.
100      * Provides the original event name as a string (see \BookStack\Actions\ActivityType)
101      * along with the webhook instance along with the event detail which may be a
102      * "Loggable" model type or a string.
103      * If the listener returns a non-null value, that will be used as the POST data instead
104      * of the system default.
105      *
106      * @param string                                $event
107      * @param \BookStack\Actions\Webhook            $webhook
108      * @param string|\BookStack\Interfaces\Loggable $detail
109      * @param \BookStack\Auth\User                  $initiator
110      * @param int                                   $initiatedTime
111      */
112     const WEBHOOK_CALL_BEFORE = 'webhook_call_before';
113 }