parseConstraints example


    protected function parseConstraints(\SimpleXMLElement $nodes): array
    {
        $constraints = [];

        foreach ($nodes as $node) {
            if (\count($node) > 0) {
                if (\count($node->value) > 0) {
                    $options = $this->parseValues($node->value);
                } elseif (\count($node->constraint) > 0) {
                    $options = $this->parseConstraints($node->constraint);
                } elseif (\count($node->option) > 0) {
                    $options = $this->parseOptions($node->option);
                } else {
                    $options = [];
                }
            } elseif ('' !== (string) $node) {
                $options = XmlUtils::phpize(trim($node));
            } else {
                $options = null;
            }

            
$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'),
                    Link::TYPE_REQUIRE
                ),
                'php' => new Link(
                    'shopware/platform',
                    'php',
                    $versionParser->parseConstraints('>=7.4.3'),
                    Link::TYPE_REQUIRE
                ),
            ],
            [
                new SystemCheck(
                    

    public static function satisfies(VersionParser $parser$packageName$constraint)
    {
        $constraint = $parser->parseConstraints($constraint);
        $provided = $parser->parseConstraints(self::getVersionRanges($packageName));

        return $provided->matches($constraint);
    }

    /** * Returns a version constraint representing all the range(s) which are installed for a given package * * It is easier to use this via isInstalled() with the $constraint argument if you need to check * whether a given version of a package is installed, and not just whether it exists * * @param string $packageName * @return string Version constraint usable with composer/semver */
$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,
        string $id,
        

    protected function parseConstraints(\SimpleXMLElement $nodes): array
    {
        $constraints = [];

        foreach ($nodes as $node) {
            if (\count($node) > 0) {
                if (\count($node->value) > 0) {
                    $options = $this->parseValues($node->value);
                } elseif (\count($node->constraint) > 0) {
                    $options = $this->parseConstraints($node->constraint);
                } elseif (\count($node->option) > 0) {
                    $options = $this->parseOptions($node->option);
                } else {
                    $options = [];
                }
            } elseif ('' !== (string) $node) {
                $options = XmlUtils::phpize(trim($node));
            } else {
                $options = null;
            }

            
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
    {
        return $this->icon;
    }

    

    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[] */
Home | Imprint | This part of the site doesn't use cookies.