Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Factory.php

function Factory::createInstanceFor

Create a constraint instance for the given constraint name.

Parameters

string $constraintName:

Return value

ConstraintInterface|ObjectConstraint

Throws

InvalidArgumentException if is not possible create the constraint instance

File

vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.php, line 188

Class

Factory
Factory for centralize constraint initialization.

Namespace

JsonSchema\Constraints

Code

public function createInstanceFor($constraintName) {
    if (!isset($this->constraintMap[$constraintName])) {
        throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
    }
    if (!isset($this->instanceCache[$constraintName])) {
        $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
    }
    return clone $this->instanceCache[$constraintName];
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal