StaticDiscoveryDecorator example

parent::__construct('Plugin/Validation/Constraint', $namespaces$module_handler, NULL, 'Drupal\Core\Validation\Annotation\Constraint');
    $this->alterInfo('validation_constraint');
    $this->setCacheBackend($cache_backend, 'validation_constraint_plugins');
  }

  /** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!isset($this->discovery)) {
      $this->discovery = parent::getDiscovery();
      $this->discovery = new StaticDiscoveryDecorator($this->discovery, [$this, 'registerDefinitions']);
    }
    return $this->discovery;
  }

  /** * Creates a validation constraint. * * @param string $name * The name or plugin id of the constraint. * @param mixed $options * The options to pass to the constraint class. Required and supported * options depend on the constraint class. * * @return \Symfony\Component\Validator\Constraint * A validation constraint plugin. */
Home | Imprint | This part of the site doesn't use cookies.