Joomlatools\Console\Application::getPlugins PHP Method

getPlugins() public method

Get the list of installed plugin packages.
public getPlugins ( ) : array
return array Array of package names as key and their version as value
    public function getPlugins()
    {
        if (!$this->_plugins) {
            $manifest = $this->_plugin_path . '/composer.json';
            if (!file_exists($manifest)) {
                return array();
            }
            $contents = file_get_contents($manifest);
            if ($contents === false) {
                return array();
            }
            $data = json_decode($contents);
            if (!isset($data->require)) {
                return array();
            }
            $this->_plugins = array();
            foreach ($data->require as $package => $version) {
                $file = $this->_plugin_path . '/vendor/' . $package . '/composer.json';
                if (file_exists($file)) {
                    $json = file_get_contents($file);
                    $manifest = json_decode($json);
                    if (is_null($manifest)) {
                        continue;
                    }
                    if (isset($manifest->type) && $manifest->type == 'joomlatools-console-plugin') {
                        $this->_plugins[$package] = $version;
                    }
                }
            }
        }
        return $this->_plugins;
    }