Total Complexity | 7 |
Total Lines | 70 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
7 | abstract class ModuleJoint |
||
8 | { |
||
9 | use Concerns\HasLinks; |
||
10 | use Concerns\HasAccessControl; |
||
11 | use Concerns\HasPackageManifest; |
||
12 | |||
13 | /** |
||
14 | * List of runtime registered joints |
||
15 | * Can be used for tesing purposes |
||
16 | * |
||
17 | * @var array |
||
18 | */ |
||
19 | protected static $registry = []; |
||
20 | |||
21 | /** |
||
22 | * Make all joints which are applicable to static class and user has access to |
||
23 | * |
||
24 | * @return Collection |
||
25 | */ |
||
26 | final public static function collect() |
||
27 | { |
||
28 | $ret = collect(); |
||
29 | foreach (self::list() as $class) { |
||
30 | /** |
||
31 | * @var ModuleJoint $joint |
||
32 | */ |
||
33 | $joint = new $class(); |
||
34 | |||
35 | if (! $joint->access()) continue; |
||
36 | |||
37 | $ret->add($joint); |
||
38 | } |
||
39 | |||
40 | return $ret; |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * List all registered joints which are subclasses of static |
||
45 | */ |
||
46 | final public static function list() |
||
56 | }); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Collect all joints declared in the modules and return array |
||
61 | * |
||
62 | * @return array |
||
63 | */ |
||
64 | final public static function moduleJoints() |
||
72 | } |
||
73 | |||
74 | final public static function register($class) |
||
77 | } |
||
78 | } |