ConfigValidator example

use Shopware\Core\Framework\Plugin\Exception\PluginComposerJsonInvalidException;

#[Package('core')] class PackageProvider
{
    /** * @throws PluginComposerJsonInvalidException */
    public function getPluginComposerPackage(string $pluginPath, IOInterface $composerIO): CompletePackageInterface
    {
        $composerJsonPath = $pluginPath . '/composer.json';
        $validator = new ConfigValidator($composerIO);

        [$errors$publishErrors$warnings] = $validator->validate($composerJsonPath, ValidatingArrayLoader::CHECK_ALL, 0);
        $errors = [...$errors, ...$publishErrors];
        if (\count($errors) !== 0) {
            throw new PluginComposerJsonInvalidException($composerJsonPath$errors);
        }

        if (\count($warnings) !== 0) {
            $warningsString = implode("\n", $warnings);
            $composerIO->write(sprintf("Attention!\nThe '%s' has some warnings:\n%s", $composerJsonPath$warningsString));
        }

        
Home | Imprint | This part of the site doesn't use cookies.