|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Projet : php-abac. |
|
4
|
|
|
* User: mvedie |
|
5
|
|
|
* Date: 24/11/2016 |
|
6
|
|
|
* Time: 18:51 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace PhpAbac\Loader; |
|
10
|
|
|
|
|
11
|
|
|
use PhpAbac\Manager\ConfigurationManager; |
|
12
|
|
|
use Symfony\Component\Config\FileLocatorInterface; |
|
13
|
|
|
use Symfony\Component\Config\Loader\FileLoader; |
|
14
|
|
|
|
|
15
|
|
|
abstract class AbacLoader extends FileLoader { |
|
16
|
|
|
/** |
|
17
|
|
|
* Must be overrided to contains an array of allowed extension |
|
18
|
|
|
*/ |
|
19
|
|
|
protected static $_EXTENSION_ALLOWED_A = []; |
|
20
|
|
|
|
|
21
|
|
|
/** @var ConfigurationManager The configuration manage instanciator and user of this AbacLoader Instance */ |
|
22
|
|
|
protected $configurationManger; |
|
23
|
|
|
|
|
24
|
18 |
|
public function __construct( FileLocatorInterface $locator ) { |
|
|
|
|
|
|
25
|
18 |
|
parent::__construct( $locator ); |
|
26
|
18 |
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Method to load a resource and return an array that contains decoded data of the resource |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $resource The path of the resource to load |
|
32
|
|
|
* @param null $type ?? |
|
33
|
|
|
* |
|
34
|
|
|
* @return string |
|
35
|
|
|
*/ |
|
36
|
|
|
abstract public function load( $resource, $type = null ); |
|
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
// /** |
|
39
|
|
|
// * Method to check if a resource ( by his path ) is supported by the loader |
|
40
|
|
|
// * |
|
41
|
|
|
// * @param string $resource The path of the resource to check |
|
42
|
|
|
// * @param null $type ?? |
|
43
|
|
|
// * |
|
44
|
|
|
// * @return boolean Return true if the resource is supported by the loader |
|
45
|
|
|
// */ |
|
46
|
|
|
// abstract public function supports( $resource, $type = null ); |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Method to check if a resource is supported by the loader |
|
50
|
|
|
* This method check only extension file |
|
51
|
|
|
* |
|
52
|
|
|
* @param $resource |
|
53
|
|
|
* |
|
54
|
|
|
* @return boolean Return true if the extension of the ressource is supported by the loader |
|
55
|
|
|
*/ |
|
56
|
18 |
|
public static final function supportsExtension( $resource ) { |
|
|
|
|
|
|
57
|
18 |
|
return in_array( pathinfo( $resource, PATHINFO_EXTENSION ), self::getExtensionAllowed() ); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Method to return allowed extension for file to load with the loader |
|
62
|
|
|
* @return mixed |
|
63
|
|
|
*/ |
|
64
|
18 |
|
private static final function getExtensionAllowed() { |
|
|
|
|
|
|
65
|
18 |
|
return static::$_EXTENSION_ALLOWED_A; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
?> |
|
|
|
|
|
|
70
|
|
|
|