-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.php
86 lines (76 loc) · 2.02 KB
/
Main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
/**
* @package Oauth
* @author Iurii Makukh <[email protected]>
* @copyright Copyright (c) 2018, Iurii Makukh <[email protected]>
* @license https://www.gnu.org/licenses/gpl-3.0.en.html GPL-3.0-or-later
*/
namespace gplcart\modules\oauth;
use gplcart\core\Container;
/**
* Main class for Oauth module
*/
class Main
{
/**
* Implements hook "route.list"
* @param array $routes
*/
public function hookRouteList(array &$routes)
{
$routes['oauth'] = array(
'internal' => true,
'handlers' => array(
'controller' => array('gplcart\\modules\\oauth\\controllers\\Oauth', 'callbackOauth')
)
);
}
/**
* Returns a provider
* @param string $id
* @return array
*/
public function getProvider($id)
{
return $this->getModel()->getProvider($id);
}
/**
* Returns an array of providers
* @param array $options
* @return array
*/
public function getProviders(array $options = array())
{
return $this->getModel()->getProviders($options);
}
/**
* Does main authorization process
* @param array $provider
* @param array $options
* @return mixed
*/
public function authorize(array $provider, array $options)
{
return $this->getModel()->authorize($provider, $options);
}
/**
* Returns the Oauth model instance
* @return \gplcart\modules\oauth\models\Oauth
*/
public function getModel()
{
/** @var \gplcart\modules\oauth\models\Oauth $instance */
$instance = Container::get('gplcart\\modules\\oauth\\models\\Oauth');
return $instance;
}
/**
* Returns JWT helper class instance
* @return \gplcart\modules\oauth\helpers\Jwt
*/
public function getJwtHelper()
{
/** @var \gplcart\modules\oauth\helpers\Jwt $instance */
$instance = Container::get('gplcart\\modules\\oauth\\helpers\\Jwt');
return $instance;
}
}