Elgg\Database\Plugins::getDirsInDir PHP Method

getDirsInDir() public method

Returns a list of plugin directory names from a base directory.
public getDirsInDir ( string $dir = null ) : array
$dir string A dir to scan for plugins. Defaults to config's plugins_path. Must have a trailing slash.
return array Array of directory names (not full paths)
    function getDirsInDir($dir = null)
    {
        if (!$dir) {
            $dir = elgg_get_plugins_path();
        }
        $plugin_dirs = array();
        $handle = opendir($dir);
        if ($handle) {
            while ($plugin_dir = readdir($handle)) {
                // must be directory and not begin with a .
                if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
                    $plugin_dirs[] = $plugin_dir;
                }
            }
        }
        sort($plugin_dirs);
        return $plugin_dirs;
    }