getPluginComposerPackage example

$filesystemPlugins = (new Finder())
                ->directories()
                ->depth(0)
                ->in($pluginDir)
                ->sortByName()
                ->getIterator();

            foreach ($filesystemPlugins as $filesystemPlugin) {
                $pluginPath = $filesystemPlugin->getRealPath();

                try {
                    $package = $this->packageProvider->getPluginComposerPackage($pluginPath$composerIO);
                } catch (PluginComposerJsonInvalidException $e) {
                    $errors->add($e);

                    continue;
                }

                if (!$this->isShopwarePluginType($package) || !$this->isPluginComposerValid($package)) {
                    $this->addError($pluginPath$errors);

                    continue;
                }

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

/** * @internal */
class PackageProviderTest extends TestCase
{
    public function testGetPluginInformation(): void
    {
        $packageProvider = $this->createProvider();
        $pluginPath = __DIR__ . '/_fixture/valid';
        $package = $packageProvider->getPluginComposerPackage($pluginPathnew NullIO());

        static::assertSame('test/test', $package->getName());
    }

    public function testGetPluginInformationInvalidJson(): void
    {
        $packageProvider = $this->createProvider();
        $pluginPath = __DIR__ . '/_fixture/invalid';

        $this->expectException(PluginComposerJsonInvalidException::class);
        $this->expectExceptionMessage('name : The property name is required');
        
Home | Imprint | This part of the site doesn't use cookies.