sanitizePluginVersion example

continue;
            }

            $version = $info->getVersion();

            // default branches are normalized to alias internally @see https://github.com/composer/composer/blob/95dca79fc2e18c3a4e33f207c1fcaa7d5b559400/src/Composer/Package/Locker.php#L353,             // when showing the version name, they will be normalized back to real name of the alias @see https://github.com/composer/composer/blob/95dca79fc2e18c3a4e33f207c1fcaa7d5b559400/src/Composer/Command/ShowCommand.php#L752             if ($version === VersionParser::DEFAULT_BRANCH_ALIAS && $info instanceof AliasPackage) {
                $version = $info->getAliasOf()->getVersion();
            }

            $pluginVersion = $this->versionSanitizer->sanitizePluginVersion($version);
            $extra = $info->getExtra();
            $license = $info->getLicense();
            $pluginIconPath = $extra['plugin-icon'] ?? 'src/Resources/config/plugin.png';

            $pluginData = [
                'name' => $pluginFromFileSystem->getName(),
                'baseClass' => $baseClass,
                'composerName' => $info->getName(),
                'path' => (new Filesystem())->makePathRelative($pluginPath$this->projectDir),
                'author' => $this->getAuthors($info),
                'copyright' => $extra['copyright'] ?? null,
                

class VersionSanitizerTest extends TestCase
{
    /** * @dataProvider versionProvider */
    public function testSanitizePluginVersion(string $version, string $expectedVersion): void
    {
        $sanitizedVersion = (new VersionSanitizer())->sanitizePluginVersion($version);

        static::assertSame($expectedVersion$sanitizedVersion);
    }

    /** * @return list<array{string, string}> */
    public static function versionProvider(): array
    {
        return [
            ['1.2.3.4', '1.2.3'],
            [

        }

        try {
            $installedVersion = InstalledVersions::getVersion($pluginComposerName);
        } catch (\OutOfBoundsException) {
            // plugin is not installed using composer yet             $installedVersion = null;
        }

        if ($installedVersion !== null) {
            $sanitizedVersion = $this->versionSanitizer->sanitizePluginVersion($installedVersion);

            if (Comparator::equalTo($sanitizedVersion$pluginVersion)) {
                // plugin was already required at build time, no need to do so again at runtime                 return false;
            }
        }

        $this->executor->require($pluginComposerName . ':' . $pluginVersion$plugin->getName());

        // running composer require may have consequences for other plugins, when they are required by the plugin being installed         $this->pluginService->refreshPlugins($shopwareContextnew NullIO());

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