contao / manager-plugin

Contao Manager Plugin
GNU Lesser General Public License v3.0
4 stars 9 forks source link

contao-manager-plugin support for /src in main composer.json #12

Closed gebi84 closed 6 years ago

gebi84 commented 6 years ago

It would be nice to also scan for 'contao-manager-plugin' in extra in the main composer.json and not only in the installed.json.

my quick workaround was:

#/vendor/contao/manager-plugin/src/PluginLoader.php:160`
$json = json_decode(file_get_contents(__DIR__.'/../../../../composer.json'), true);
if (isset($json['extra']['contao-manager-plugin'])) {
    if (!class_exists($json['extra']['contao-manager-plugin'])) {
        throw new \RuntimeException(
            sprintf('Plugin class "%s" not found', $json['extra']['contao-manager-plugin'])
        );
    }

    $plugins[$json['name']] = new $json['extra']['contao-manager-plugin']();
}

my Code lives in ROOT/src/VENDOR/BUNDLE my composer.json:

"autoload": {
    "psr-4": { "VENDOR\\BUNDLE\\": "src/VENDOR/BUNDLE/" }
}

Or am I wrong?

aschempp commented 6 years ago

Imho there is no need for that. You can simply add a ContaoManagerPlugin class to the global namespace and it will be loaded automatically. See https://docs.contao.org/books/extending-contao4/managed-edition/#adding-a-manager-plugin

gebi84 commented 6 years ago

Thx i will try that later

... works perfekt thank you.