-
Notifications
You must be signed in to change notification settings - Fork 57
/
normalizedrivertypes.php
67 lines (58 loc) · 1.57 KB
/
normalizedrivertypes.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
<?php
/**
* Fuel is a fast, lightweight, community driven PHP 5.4+ framework.
*
* @package Fuel
* @version 1.9-dev
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2019 Fuel Development Team
* @link https://fuelphp.com
*/
/**
* Attempt to determine whether the app is SimpleAuth or OrmAuth based
*
* @return string normalized Auth driver
*/
if ( ! function_exists('normalize_driver_types'))
{
function normalize_driver_types()
{
// get the drivers configured
\Config::load('auth', true);
$drivers = \Config::get('auth.driver', array());
is_array($drivers) or $drivers = array($drivers);
$results = array();
foreach ($drivers as $driver)
{
// determine the driver classname
$class = \Inflector::get_namespace($driver).'Auth_Login_'.\Str::ucwords(\Inflector::denamespace($driver));
// Auth's Simpleauth
if ($class == 'Auth_Login_Simpleauth' or $class == 'Auth\Auth_Login_Simpleauth')
{
$driver = 'Simpleauth';
}
// Auth's Ormauth
elseif ($class == 'Auth_Login_Ormauth' or $class == 'Auth\Auth_Login_Ormauth')
{
$driver = 'Ormauth';
}
elseif (class_exists($class))
{
// Extended fromm Auth's Simpleauth
if (get_parent_class($class) == 'Auth\Auth_Login_Simpleauth')
{
$driver = 'Simpleauth';
}
// Extended fromm Auth's Ormauth
elseif (get_parent_class($class) == 'Auth\Auth_Login_Ormauth')
{
$driver = 'Ormauth';
}
}
// store the normalized driver name
in_array($driver, $results) or $results[] = $driver;
}
return $results;
}
}