src/Core/Manifest/ModuleManifest.php
public function getModuleByPath($path)
    {
        // Ensure path exists
        $path = realpath($path);
        if (!$path) {
            return null;
        }

        /** @var Module $rootModule */
        $rootModule = null;

        // Find based on loaded modules
        $modules = ModuleLoader::inst()->getManifest()->getModules();
        foreach ($modules as $module) {
            // Check if path is in module
            if (stripos($path, realpath($module->getPath())) !== 0) {
                continue;
            }

            // If this is the root module, keep looking in case there is a more specific module later
            if (empty($module->getRelativePath())) {
                $rootModule = $module;
            } else {
                return $module;
            }
        }

        // Fall back to top level module
        return $rootModule;
    }
public function getModuleByPath($path)
    {
        // Ensure path exists
        $path = realpath($path);
        if (!$path) {
            return null;
        }

        /** @var Module $rootModule */
        $rootModule = null;

        // Find based on loaded modules
        $modules = ModuleLoader::inst()->getManifest()->getModules();
        foreach ($modules as $module) {
            // Check if path is in module
            if (stripos($path, realpath($module->getPath())) !== 0) {
                continue;
            }

            // If this is the root module, keep looking in case there is a more specific module later
            if (empty($module->getRelativePath())) {
                $rootModule = $module;
            } else {
                return $module;
            }
        }

        // Fall back to top level module
        return $rootModule;
    }
public function getModuleByPath ( $ path ) { // Ensure path exists $ path = realpath ( $ path ) ; if ( ! $ path ) { return null ; } /** @var Module $rootModule */ $ rootModule = null ; // Find based on loaded modules $ modules = ModuleLoader :: inst ( ) -> getManifest ( ) -> getModules ( ) ; foreach ( $ modules as $ module ) { // Check if path is in module if ( stripos ( $ path , realpath ( $ module -> getPath ( ) ) ) !== 0 ) { continue ; } // If this is the root module, keep looking in case there is a more specific module later if ( empty ( $ module -> getRelativePath ( ) ) ) { $ rootModule = $ module ; } else { return $ module ; } } // Fall back to top level module return $ rootModule ; }
Get module that contains the given path

@param string $path Full filesystem path to the given file
@return Module The module, or null if not a path in any module
Get module that contains the given path