GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — 3.0 ( 5276e1...94e02b )
by Vermeulen
01:25
created

ModuleList::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace BFW\Core\AppSystems;
4
5
class ModuleList extends AbstractSystem
6
{
7
    /**
8
     * @var \BFW\Core\ModuleList $moduleList
9
     */
10
    protected $moduleList;
11
    
12
    /**
13
     * Initialize the ModuleList system
14
     */
15
    public function __construct()
16
    {
17
        $this->moduleList = new \BFW\Core\ModuleList;
18
    }
19
    
20
    /**
21
     * {@inheritdoc}
22
     * 
23
     * @return \BFW\Core\ModuleList
24
     */
25
    public function __invoke()
26
    {
27
        return $this->moduleList;
28
    }
29
30
    /**
31
     * Getter accessor to property moduleList
32
     * 
33
     * @return \BFW\Core\ModuleList
34
     */
35
    public function getModuleList()
36
    {
37
        return $this->moduleList;
38
    }
39
    
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function toRun(): bool
44
    {
45
        return true;
46
    }
47
    
48
    /**
49
     * {@inheritdoc}
50
     * 
51
     * Load all modules, run all core and app modules
52
     */
53
    public function run()
54
    {
55
        $this->loadAllModules();
56
        $this->runAllCoreModules();
57
        $this->runAllAppModules();
58
        
59
        $this->runStatus = true;
60
    }
61
    
62
    /**
63
     * Read all directories in modules directory and add each module to Modules
64
     * class.
65
     * Generate the load tree.
66
     * Not initialize modules !
67
     * 
68
     * @return void
69
     */
70
    protected function loadAllModules()
71
    {
72
        $listModules = array_diff(scandir(MODULES_DIR), ['.', '..']);
73
74
        foreach ($listModules as $moduleName) {
75
            $modulePath = realpath(MODULES_DIR.$moduleName); //Symlink
76
77
            if (!is_dir($modulePath)) {
78
                continue;
79
            }
80
81
            $this->moduleList->addModule($moduleName);
82
        }
83
84
        $this->moduleList->readNeedMeDependencies();
85
        $this->moduleList->generateTree();
86
    }
87
88
    /**
89
     * Load core modules defined into config bfw file.
90
     * Only module for controller, router, database and template only.
91
     * 
92
     * @return void
93
     */
94
    protected function runAllCoreModules()
95
    {
96
        $allModules = \BFW\Application::getInstance()
97
            ->getConfig()
98
            ->getValue('modules', 'modules.php')
99
        ;
100
        
101
        foreach ($allModules as $moduleInfos) {
102
            $moduleName    = $moduleInfos['name'];
103
            $moduleEnabled = $moduleInfos['enabled'];
104
105
            if (empty($moduleName) || $moduleEnabled === false) {
106
                continue;
107
            }
108
109
            $this->runModule($moduleName);
110
        }
111
    }
112
113
    /**
114
     * Load all modules (except core).
115
     * Get the load tree, read him and load all modules with the order
116
     * declared into the tree.
117
     * 
118
     * @return void
119
     */
120
    protected function runAllAppModules()
121
    {
122
        $tree = $this->moduleList->getLoadTree();
123
124
        foreach ($tree as $firstLine) {
125
            foreach ($firstLine as $secondLine) {
126
                foreach ($secondLine as $moduleName) {
127
                    $this->runModule($moduleName);
128
                }
129
            }
130
        }
131
    }
132
133
    /**
134
     * Load a module
135
     * 
136
     * @param string $moduleName The module's name to load
137
     * 
138
     * @return void
139
     */
140
    protected function runModule(string $moduleName)
141
    {
142
        $app = \BFW\Application::getInstance();
143
        
144
        $app->getSubjectList()
145
            ->getSubjectByName('ApplicationTasks')
146
            ->sendNotify('BfwApp_run_module_'.$moduleName);
147
        
148
        $this->moduleList
149
            ->getModuleByName($moduleName)
150
            ->runModule();
151
    }
152
}
153