1 | <?php |
||
31 | class Patron extends Plugin |
||
32 | { |
||
33 | /** |
||
34 | * @inheritdoc |
||
35 | */ |
||
36 | 15 | public function init() |
|
87 | |||
88 | /** |
||
89 | * @inheritdoc |
||
90 | * @return SettingsModel |
||
91 | */ |
||
92 | public function createSettingsModel() |
||
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | */ |
||
100 | protected function settingsHtml() |
||
101 | { |
||
102 | return Craft::$app->getView()->renderTemplate( |
||
103 | 'patron/settings', |
||
104 | [ |
||
105 | 'settings' => $this->getSettings() |
||
106 | ] |
||
107 | ); |
||
108 | } |
||
109 | |||
110 | /******************************************* |
||
111 | * SERVICES |
||
112 | *******************************************/ |
||
113 | |||
114 | /** |
||
115 | * @noinspection PhpDocMissingThrowsInspection |
||
116 | * @return services\Providers |
||
117 | */ |
||
118 | 3 | public function getProviders(): services\Providers |
|
119 | { |
||
120 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
121 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
||
122 | 3 | return $this->get('providers'); |
|
123 | } |
||
124 | |||
125 | /** |
||
126 | * @noinspection PhpDocMissingThrowsInspection |
||
127 | * @return services\Tokens |
||
128 | */ |
||
129 | 3 | public function getTokens(): services\Tokens |
|
130 | { |
||
131 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
132 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
||
133 | 3 | return $this->get('tokens'); |
|
134 | } |
||
135 | |||
136 | /** |
||
137 | * @noinspection PhpDocMissingThrowsInspection |
||
138 | * @return services\ManageProviders |
||
139 | */ |
||
140 | 3 | public function manageProviders(): services\ManageProviders |
|
141 | { |
||
142 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
143 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
||
144 | 3 | return $this->get('manageProviders'); |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * @noinspection PhpDocMissingThrowsInspection |
||
149 | * @return services\ManageTokens |
||
150 | */ |
||
151 | 3 | public function manageTokens(): services\ManageTokens |
|
152 | { |
||
153 | /** @noinspection PhpUnhandledExceptionInspection */ |
||
154 | /** @noinspection PhpIncompatibleReturnTypeInspection */ |
||
155 | 3 | return $this->get('manageTokens'); |
|
156 | } |
||
157 | |||
158 | /** |
||
159 | * @noinspection PhpDocMissingThrowsInspection |
||
160 | * @return services\Session |
||
161 | */ |
||
162 | 3 | public function getSession(): services\Session |
|
168 | |||
169 | |||
170 | /******************************************* |
||
171 | * EVENTS |
||
172 | *******************************************/ |
||
173 | |||
174 | /** |
||
175 | * @param RegisterUrlRulesEvent $event |
||
176 | */ |
||
177 | public static function onRegisterCpUrlRules(RegisterUrlRulesEvent $event) |
||
190 | |||
191 | |||
192 | /******************************************* |
||
193 | * LOGGING |
||
194 | *******************************************/ |
||
195 | |||
196 | /** |
||
197 | * Logs an informative message. |
||
198 | * |
||
199 | * @param $message |
||
200 | * @param string $category |
||
201 | */ |
||
202 | public static function info($message, $category = 'patron') |
||
206 | |||
207 | /** |
||
208 | * Logs a warning message. |
||
209 | * |
||
210 | * @param $message |
||
211 | * @param string $category |
||
212 | */ |
||
213 | public static function warning($message, $category = 'patron') |
||
217 | |||
218 | /** |
||
219 | * Logs an error message. |
||
220 | * |
||
221 | * @param $message |
||
222 | * @param string $category |
||
223 | */ |
||
224 | public static function error($message, $category = 'patron') |
||
228 | } |
||
229 |