getDiscovery example

if (!isset($this->factory)) {
      $this->factory = new ContainerFactory($this);
    }
    return $this->factory;
  }

  /** * {@inheritdoc} */
  public function getDefinitions() {
    // Since this function is called rarely, instantiate the discovery here.     $definitions = $this->getDiscovery()->getDefinitions();

    $this->moduleHandler->alter('menu_links_discovered', $definitions);

    foreach ($definitions as $plugin_id => &$definition) {
      $definition['id'] = $plugin_id;
      $this->processDefinition($definition$plugin_id);
    }

    // If this plugin was provided by a module that does not exist, remove the     // plugin definition.     // @todo Address what to do with an invalid plugin.
/** * {@inheritdoc} */
  public function buildDataDefinition(array $definition$value = NULL, $name = NULL, $parent = NULL) {
    return $this->typedConfigManager->buildDataDefinition($definition$value$name$parent);
  }

  /** * {@inheritdoc} */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    foreach ($definitions as $plugin_id => &$definition) {
      $this->processDefinition($definition$plugin_id);
    }
    if ($this->alterHook) {
      $this->moduleHandler->alter($this->alterHook, $definitions);
    }

    // If this plugin was provided by a module that does not exist, remove the     // plugin definition.     foreach ($definitions as $plugin_id => $plugin_definition) {
      if (isset($plugin_definition['provider']) && !in_array($plugin_definition['provider']['core', 'component']) && (!$this->moduleHandler->moduleExists($plugin_definition['provider']) && !in_array($plugin_definition['provider']array_keys($this->themeHandler->listInfo())))) {
        

    return $this->factory;
  }

  /** * Finds plugin definitions. * * @return array * List of definitions to store in cache. */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    foreach ($definitions as $plugin_id => &$definition) {
      $this->processDefinition($definition$plugin_id);
    }
    $this->alterDefinitions($definitions);
    // If this plugin was provided by a module that does not exist, remove the     // plugin definition.     foreach ($definitions as $plugin_id => $plugin_definition) {
      $provider = $this->extractProviderFromDefinition($plugin_definition);
      if ($provider && !in_array($provider['core', 'component']) && !$this->providerExists($provider)) {
        unset($definitions[$plugin_id]);
      }
    }
    foreach ((array) $definition->getLinkTemplates() as $link_relation_name => $link_template) {
      if ($link_template[0] != '/') {
        throw new InvalidLinkTemplateException("Link template '$link_relation_name' for entity type '$plugin_id' must start with a leading slash, the current link template is '$link_template'");
      }
    }
  }

  /** * {@inheritdoc} */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    $this->moduleHandler->invokeAllWith('entity_type_build', function Dcallable $hook, string $module) use (&$definitions) {
      $hook($definitions);
    });
    foreach ($definitions as $plugin_id => $definition) {
      $this->processDefinition($definition$plugin_id);
    }
    $this->alterDefinitions($definitions);

    return $definitions;
  }

  

  protected function getFactory() {
    return $this->factory;
  }

  /** * {@inheritdoc} */
  public function getDefinition($plugin_id$exception_on_invalid = TRUE) {
    return $this->getDiscovery()->getDefinition($plugin_id$exception_on_invalid);
  }

  /** * {@inheritdoc} */
  public function getDefinitions() {
    return $this->getDiscovery()->getDefinitions();
  }

  /** * {@inheritdoc} */
/** * Finds plugin definitions. * * @return array * List of definitions to store in cache. * * @todo This is a temporary solution to the fact that migration source * plugins have more than one provider. This functionality will be moved to * core in https://www.drupal.org/node/2786355. */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    foreach ($definitions as $plugin_id => &$definition) {
      $this->processDefinition($definition$plugin_id);
    }
    $this->alterDefinitions($definitions);
    return ProviderFilterDecorator::filterDefinitions($definitionsfunction D$provider) {
      return $this->providerExists($provider);
    });
  }

}
/** * Finds plugin definitions. * * @return array * List of definitions to store in cache. * * @todo This is a temporary solution to the fact that migration source * plugins have more than one provider. This functionality will be moved to * core in https://www.drupal.org/node/2786355. */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    foreach ($definitions as $plugin_id => &$definition) {
      $this->processDefinition($definition$plugin_id);
    }
    $this->alterDefinitions($definitions);
    return ProviderFilterDecorator::filterDefinitions($definitionsfunction D$provider) {
      return $this->providerExists($provider);
    });
  }

}
$this->factory = new ConstraintFactory($this);
    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.