1 | <?php namespace VojtaSvoboda\CnbRates; |
||
2 | |||
3 | use System\Classes\PluginBase; |
||
4 | use VojtaSvoboda\CnbRates\Models\Settings; |
||
5 | |||
6 | /** |
||
7 | * CnbRates Plugin Information File |
||
8 | */ |
||
9 | class Plugin extends PluginBase |
||
10 | { |
||
11 | /** |
||
12 | * Returns information about this plugin. |
||
13 | * |
||
14 | * @return array |
||
15 | */ |
||
16 | public function pluginDetails() |
||
17 | { |
||
18 | return [ |
||
19 | 'name' => 'vojtasvoboda.cnbrates::lang.plugin.name', |
||
20 | 'description' => 'vojtasvoboda.cnbrates::lang.plugin.description', |
||
21 | 'author' => 'Vojta Svoboda', |
||
22 | 'icon' => 'icon-line-chart' |
||
23 | ]; |
||
24 | } |
||
25 | |||
26 | 1 | public function boot() |
|
27 | 1 | { |
|
28 | $this->app->bind('cnb', 'VojtaSvoboda\CnbRates\Facades\CnbFacade'); |
||
29 | } |
||
30 | |||
31 | public function registerSettings() |
||
32 | { |
||
33 | return [ |
||
34 | 'config' => [ |
||
35 | 'label' => 'vojtasvoboda.cnbrates::lang.settings.label', |
||
36 | 'icon' => 'icon-line-chart', |
||
37 | 'description' => 'vojtasvoboda.cnbrates::lang.settings.description', |
||
38 | 'class' => 'VojtaSvoboda\CnbRates\Models\Settings', |
||
39 | 'order' => 500 |
||
40 | ] |
||
41 | ]; |
||
42 | } |
||
43 | |||
44 | 26 | public function registerSchedule($schedule) |
|
45 | { |
||
46 | // Exchange service daily update when allowed by Settings |
||
47 | $schedule->call(function() { |
||
48 | $cnb = $this->app->make('cnb'); |
||
49 | $cnb->updateTodayExchangeRates(); |
||
50 | |||
51 | })->daily()->when(function() { |
||
52 | return !!Settings::get('exchange', true); |
||
53 | 26 | }); |
|
54 | |||
55 | // PRIBOR service daily update when allowed by Settings |
||
56 | $schedule->call(function() { |
||
57 | $cnb = $this->app->make('cnb'); |
||
58 | $cnb->updateTodayPriborRates(); |
||
59 | |||
60 | 26 | })->daily()->when(function() { |
|
61 | return !!Settings::get('pribor', true); |
||
62 | 26 | }); |
|
63 | 26 | } |
|
64 | |||
65 | } |