1 | <?php |
||
42 | class Patron extends Plugin |
||
43 | { |
||
44 | use LoggerTrait; |
||
45 | |||
46 | /** |
||
47 | * @var string |
||
48 | */ |
||
49 | public static $category = 'patron'; |
||
50 | |||
51 | /** |
||
52 | * The before persist token event name |
||
53 | */ |
||
54 | const EVENT_BEFORE_PERSIST_TOKEN = 'beforePersistToken'; |
||
55 | |||
56 | /** |
||
57 | * The after persist token event name |
||
58 | */ |
||
59 | const EVENT_AFTER_PERSIST_TOKEN = 'afterPersistToken'; |
||
60 | |||
61 | /** |
||
62 | * @return string |
||
63 | */ |
||
64 | protected static function getLogFileName(): string |
||
68 | |||
69 | 3 | /** |
|
70 | * @inheritdoc |
||
71 | */ |
||
72 | 3 | public function init() |
|
123 | |||
124 | 3 | /** |
|
125 | * Register project config events, if we're able to |
||
126 | */ |
||
127 | protected function registerProjectConfigEvents() |
||
236 | |||
237 | |||
238 | /******************************************* |
||
239 | * NAV |
||
240 | *******************************************/ |
||
241 | |||
242 | /** |
||
243 | * @inheritdoc |
||
244 | */ |
||
245 | public function getCpNavItem() |
||
263 | |||
264 | |||
265 | /******************************************* |
||
266 | * SETTINGS |
||
267 | *******************************************/ |
||
268 | |||
269 | /** |
||
270 | * @inheritdoc |
||
271 | * @return SettingsModel |
||
272 | */ |
||
273 | public function createSettingsModel() |
||
277 | |||
278 | /** |
||
279 | * @inheritdoc |
||
280 | * @throws \yii\base\ExitException |
||
281 | */ |
||
282 | public function getSettingsResponse() |
||
290 | |||
291 | /******************************************* |
||
292 | * QUERIES |
||
293 | *******************************************/ |
||
294 | |||
295 | /** |
||
296 | * @param array $config |
||
297 | * @return ProviderQuery |
||
298 | */ |
||
299 | public function getProviders(array $config = []): ProviderQuery |
||
300 | { |
||
301 | $query = new ProviderQuery(); |
||
302 | |||
303 | QueryHelper::configure( |
||
304 | $query, |
||
305 | $config |
||
306 | ); |
||
307 | |||
308 | return $query; |
||
309 | } |
||
310 | |||
311 | /** |
||
312 | * @param array $config |
||
313 | * @return TokenQuery |
||
314 | */ |
||
315 | public function getTokens(array $config = []): TokenQuery |
||
316 | { |
||
317 | $query = new TokenQuery(); |
||
318 | |||
319 | QueryHelper::configure( |
||
320 | $query, |
||
321 | $config |
||
322 | ); |
||
323 | |||
324 | return $query; |
||
325 | } |
||
326 | |||
327 | |||
328 | /******************************************* |
||
329 | * SERVICES |
||
330 | *******************************************/ |
||
331 | 3 | ||
332 | /** |
||
333 | * @noinspection PhpDocMissingThrowsInspection |
||
334 | * @return services\Session |
||
335 | 3 | */ |
|
336 | public function getSession(): services\Session |
||
342 | |||
343 | |||
344 | /******************************************* |
||
345 | * MODULES |
||
346 | *******************************************/ |
||
347 | |||
348 | /** |
||
349 | * @noinspection PhpDocMissingThrowsInspection |
||
350 | * @return cp\Cp |
||
351 | */ |
||
352 | public function getCp(): cp\Cp |
||
358 | |||
359 | |||
360 | /******************************************* |
||
361 | * PROVIDER SETTINGS |
||
362 | *******************************************/ |
||
363 | |||
364 | /** |
||
365 | * @param string|null $class |
||
366 | * @param array $settings |
||
367 | * @return SettingsInterface |
||
368 | * @throws \yii\base\InvalidConfigException |
||
369 | */ |
||
370 | public function providerSettings(string $class = null, $settings = []): SettingsInterface |
||
397 | |||
398 | |||
399 | /******************************************* |
||
400 | * EVENTS |
||
401 | *******************************************/ |
||
402 | |||
403 | /** |
||
404 | * @param RegisterUrlRulesEvent $event |
||
405 | */ |
||
406 | public static function onRegisterCpUrlRules(RegisterUrlRulesEvent $event) |
||
437 | |||
438 | /******************************************* |
||
439 | * TRANSLATE |
||
440 | *******************************************/ |
||
441 | |||
442 | /** |
||
443 | * Translates a message to the specified language. |
||
444 | * |
||
445 | * This is a shortcut method of [[\Craft::t()]]. |
||
446 | * * |
||
447 | * @param string $message the message to be translated. |
||
448 | * @param array $params the parameters that will be used to replace the corresponding placeholders in the message. |
||
449 | * @param string $language the language code (e.g. `en-US`, `en`). If this is null, the current |
||
450 | * [[\yii\base\Application::language|application language]] will be used. |
||
451 | * @return string the translated message. |
||
452 | */ |
||
453 | public static function t($message, $params = [], $language = null) |
||
457 | } |
||
458 |