diff options
author | Simon Rettberg | 2016-06-23 17:00:00 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-06-23 17:00:00 +0200 |
commit | 15cf181f112c296d90a9f6fc885a285f10d42037 (patch) | |
tree | 9946eac3e899149207ea9abd1f3423fdb35c00e8 | |
parent | [locations/sysconfig] Implement location specific sysconfig (diff) | |
download | slx-admin-15cf181f112c296d90a9f6fc885a285f10d42037.tar.gz slx-admin-15cf181f112c296d90a9f6fc885a285f10d42037.tar.xz slx-admin-15cf181f112c296d90a9f6fc885a285f10d42037.zip |
[module] Add getDependencies() to recursively get all deps of a module
-rw-r--r-- | inc/module.inc.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/inc/module.inc.php b/inc/module.inc.php index 336d0a5b..a7a767ef 100644 --- a/inc/module.inc.php +++ b/inc/module.inc.php @@ -182,6 +182,28 @@ class Module } } } + + public function getDependencies() + { + $deps = array(); + $this->getDepsInternal($deps); + return array_keys($deps); + } + + private function getDepsInternal(&$deps) + { + if (!is_array($this->dependencies)) + return array(); + foreach ($this->dependencies as $dep) { + if (isset($deps[$dep])) // Handle cyclic dependencies + continue; + $deps[$dep] = true; + $mod = self::get($dep); + if ($mod === false) + continue; + $mod->getDepsInternal($deps); + } + } public function getIdentifier() { |