VersionParser example

/** * Determine if given version satisfies given constraints. * * @param string $version * @param string $constraints * * @return bool */
    public static function satisfies($version$constraints)
    {
        if (null === self::$versionParser) {
            self::$versionParser = new VersionParser();
        }

        $versionParser = self::$versionParser;
        $provider = new Constraint('==', $versionParser->normalize($version));
        $parsedConstraints = $versionParser->parseConstraints($constraints);

        return $parsedConstraints->matches($provider);
    }

    /** * Return all versions that satisfy given constraints. * * @param string[] $versions * @param string $constraints * * @return string[] */


        $validator = new EnvironmentRequirementsValidator($composer$systemEnvironment);

        $checks = new RequirementsCheckCollection();

        static::assertEquals($expectedChecks$validator->validateRequirements($checks)->getElements());
    }

    public static function composerRequirementsProvider(): \Generator
    {
        $versionParser = new VersionParser();

        yield 'platform repo with satisfied requirement' => [
            'shopware/platform',
            [
                'php' => '7.4.3',
            ],
            [
                'someRequirement' => new Link(
                    'shopware/platform',
                    'someRequirement',
                    $versionParser->parseConstraints('>=1.3.0'),
                    
/** * @param array{'require': Link[], 'conflict': Link[]} $pluginDependencies * * @return array{'require': Link[], 'conflict': Link[]} */
    private function validateInstalledPlugins(
        Context $context,
        PluginEntity $installingPlugin,
        array $pluginDependencies,
        RequirementExceptionStack $exceptionStack
    ): array {
        $parser = new VersionParser();
        $pluginPackages = $this->getComposerPackagesFromPlugins();

        foreach ($this->getInstalledPlugins($context) as $pluginEntity) {
            $pluginComposerName = $pluginEntity->getComposerName();
            if ($pluginComposerName === null) {
                $exceptionStack->add(new ComposerNameMissingException($pluginEntity->getName()));

                continue;
            }

            $pluginPath = sprintf('%s/%s', $this->projectDir, $pluginEntity->getPath());

            
if ($appEntity->isActive()) {
            $this->appStateService->deactivateApp($appEntity->getId()$context);
        }

        $this->removeAppAndRole($appEntity$context$keepUserData, true);
        $this->assetService->removeAssets($appEntity->getName());
        $this->customEntitySchemaUpdater->update();
    }

    public function ensureIsCompatible(Manifest $manifest): void
    {
        $versionParser = new VersionParser();
        if (!$manifest->getMetadata()->getCompatibility()->matches($versionParser->parseConstraints($this->shopwareVersion))) {
            throw AppException::notCompatible($manifest->getMetadata()->getName());
        }
    }

    /** * @param array<string, mixed> $metadata */
    private function updateApp(
        Manifest $manifest,
        array $metadata,
        


    public function getLicense(): ?string
    {
        return $this->license;
    }

    public function getCompatibility(): ConstraintInterface
    {
        $constraint = $this->compatibility ?? '>=6.4.0';

        $parser = new VersionParser();

        return $parser->parseConstraints($constraint);
    }

    public function getVersion(): string
    {
        return $this->version;
    }

    public function getIcon(): ?string
    {
        
Home | Imprint | This part of the site doesn't use cookies.