framework/base/Controller.php
public function getModules()
    {
        $modules = [$this->module];
        $module = $this->module;
        while ($module->module !== null) {
            array_unshift($modules, $module->module);
            $module = $module->module;
        }

        return $modules;
    }
public function getModules()
    {
        $modules = [$this->module];
        $module = $this->module;
        while ($module->module !== null) {
            array_unshift($modules, $module->module);
            $module = $module->module;
        }

        return $modules;
    }
Returns all ancestor modules of this controller.
The first module in the array is the outermost one (i.e., the application instance),
while the last is the innermost one.
@return Module[] all ancestor modules that this controller is located within.