parseConstraint example


        $orGroups = array();

        foreach ($orConstraints as $constraints) {
            $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
            if (false === $andConstraints) {
                throw new \RuntimeException('Failed to preg_split string: '.$constraints);
            }
            if (\count($andConstraints) > 1) {
                $constraintObjects = array();
                foreach ($andConstraints as $constraint) {
                    foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
                        $constraintObjects[] = $parsedConstraint;
                    }
                }
            } else {
                $constraintObjects = $this->parseConstraint($andConstraints[0]);
            }

            if (1 === \count($constraintObjects)) {
                $constraint = $constraintObjects[0];
            } else {
                $constraint = new MultiConstraint($constraintObjects);
            }
/** * Constraint constructor. * * @param string $constraint * The constraint string to create the object from. For example, '>8.x-1.1'. * @param string $core_compatibility * Core compatibility declared for the current version of Drupal core. * Normally this is set to \Drupal::CORE_COMPATIBILITY by the caller. */
  public function __construct($constraint$core_compatibility) {
    $this->constraint = $constraint;
    $this->parseConstraint($constraint$core_compatibility);
  }

  /** * Gets the constraint as a string. * * Can be used in the UI for reporting incompatibilities. * * @return string * The constraint as a string. */
  public function __toString() {
    
Home | Imprint | This part of the site doesn't use cookies.