src/Module/ModuleManager.php
protected function checkPlugins($module)
    {
        $loadedPlugins = Configure::read('plugins');
        $arr = [];

        if (empty($loadedPlugins) || !is_array($loadedPlugins)) {
            return $arr;
        }

        foreach ($loadedPlugins as $plugin => $pluginPath) {
            $pluginPath = Plugin::classPath($plugin) . 'Module' . DS . 'Modules';
            $files = new DirectoryIterator($pluginPath);

            foreach ($files as $file) {
                $filename = $file->getFilename();

                if ($file->isDot() || $file->isDir() || $filename[0] == '.') {
                    continue;
                } elseif ($file->isFile() && substr($filename, -4) != '.php') {
                    continue;
                } elseif (Inflector::camelize(substr($filename, 0, -4)) !== $module) {
                    continue;
                } else {
                    $arr = ['pathDir' => $pluginPath, 'plugin' => $plugin];

                    return $arr;
                }
            }
        }

        return $arr;
    }
protected function checkPlugins($module)
    {
        $loadedPlugins = Configure::read('plugins');
        $arr = [];

        if (empty($loadedPlugins) || !is_array($loadedPlugins)) {
            return $arr;
        }

        foreach ($loadedPlugins as $plugin => $pluginPath) {
            $pluginPath = Plugin::classPath($plugin) . 'Module' . DS . 'Modules';
            $files = new DirectoryIterator($pluginPath);

            foreach ($files as $file) {
                $filename = $file->getFilename();

                if ($file->isDot() || $file->isDir() || $filename[0] == '.') {
                    continue;
                } elseif ($file->isFile() && substr($filename, -4) != '.php') {
                    continue;
                } elseif (Inflector::camelize(substr($filename, 0, -4)) !== $module) {
                    continue;
                } else {
                    $arr = ['pathDir' => $pluginPath, 'plugin' => $plugin];

                    return $arr;
                }
            }
        }

        return $arr;
    }
Check if the module exist in the plugin list. Primary used when we need to load a module and
the module doesn't exists in the application itself.

@param string $module The module to check.

@return array The config needed for the ModuleManager::load() function.