framework/base/Module.php
public function getModules($loadedOnly = false)
    {
        if ($loadedOnly) {
            $modules = [];
            foreach ($this->_modules as $module) {
                if ($module instanceof self) {
                    $modules[] = $module;
                }
            }

            return $modules;
        }

        return $this->_modules;
    }
public function getModules($loadedOnly = false)
    {
        if ($loadedOnly) {
            $modules = [];
            foreach ($this->_modules as $module) {
                if ($module instanceof self) {
                    $modules[] = $module;
                }
            }

            return $modules;
        }

        return $this->_modules;
    }
Returns the sub-modules in this module.
@param bool $loadedOnly whether to return the loaded sub-modules only. If this is set `false`,
then all sub-modules registered in this module will be returned, whether they are loaded or not.
Loaded modules will be returned as objects, while unloaded modules as configuration arrays.
@return array the modules (indexed by their IDs).