1 | <?php |
||
19 | class Cp extends Module |
||
20 | { |
||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | private $info; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $providers; |
||
30 | |||
31 | /** |
||
32 | * @inheritdoc |
||
33 | */ |
||
34 | public function init() |
||
35 | { |
||
36 | parent::init(); |
||
37 | |||
38 | RegisterProviderSettings::on( |
||
39 | Facebook::class, |
||
40 | RegisterProviderSettings::REGISTER_SETTINGS, |
||
41 | function (RegisterProviderSettings $event) { |
||
42 | $event->class = FacebookSettings::class; |
||
43 | } |
||
44 | ); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @inheritdoc |
||
49 | * @throws NotFoundHttpException |
||
50 | */ |
||
51 | public function beforeAction($action) |
||
52 | { |
||
53 | if (!Craft::$app->request->getIsCpRequest()) { |
||
54 | throw new NotFoundHttpException(); |
||
55 | } |
||
56 | |||
57 | return parent::beforeAction($action); |
||
58 | } |
||
59 | |||
60 | |||
61 | /******************************************* |
||
62 | * PROVIDERS |
||
63 | *******************************************/ |
||
64 | |||
65 | /** |
||
66 | * @return array |
||
67 | */ |
||
68 | public function getProviders(): array |
||
69 | { |
||
70 | if ($this->providers === null) { |
||
71 | $event = new RegisterProviders(); |
||
72 | |||
73 | $this->trigger( |
||
74 | $event::REGISTER_PROVIDERS, |
||
75 | $event |
||
76 | ); |
||
77 | |||
78 | $this->providers = $event->providers; |
||
79 | } |
||
80 | |||
81 | return $this->providers; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * This should give is some additional information about the provider. |
||
86 | * |
||
87 | * ``` |
||
88 | * [ |
||
89 | * Provider::class => [ |
||
90 | * 'name' => 'Provider Name', |
||
91 | * 'icon' => 'path/to/icon.svg' |
||
92 | * ] |
||
93 | * ] |
||
94 | * ``` |
||
95 | * |
||
96 | * @return array |
||
97 | * @throws \ReflectionException |
||
98 | */ |
||
99 | public function getProviderInfo(): array |
||
116 | |||
117 | /** |
||
118 | * @param array $providers |
||
119 | * @throws \ReflectionException |
||
120 | */ |
||
121 | private function formatInfoArray(array &$providers) |
||
133 | } |
||
134 |