processDefinition example

/** * {@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.     // https://www.drupal.org/node/2302623     foreach ($definitions as $plugin_id => $plugin_definition) {
      if (!empty($plugin_definition['provider']) && !$this->moduleHandler->moduleExists($plugin_definition['provider'])) {
        unset($definitions[$plugin_id]);
      }
    }
    

  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);
    });
  }

}
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
    parent::__construct('Plugin/QueueWorker', $namespaces$module_handler, 'Drupal\Core\Queue\QueueWorkerInterface', 'Drupal\Core\Annotation\QueueWorker');

    $this->setCacheBackend($cache_backend, 'queue_plugins');
    $this->alterInfo('queue_info');
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    // Safeguard to ensure the default lease time is used in the case of a     // malformed queue worker annotation where cron is specified without a time,     // or an invalid time is provided.     //     // @see \Drupal\Core\Cron::processQueues()     if (isset($definition['cron'])) {
      $time = $definition['cron']['time'] ?? 0;
      if ($time <= 0) {
        $definition['cron']['time'] = self::DEFAULT_QUEUE_CRON_TIME;
      }
    }
$discovery = new AnnotationBridgeDecorator($discovery$this->pluginDefinitionAnnotationName);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    if (!$definition instanceof LayoutDefinition) {
      throw new InvalidPluginDefinitionException($plugin_idsprintf('The "%s" layout definition must extend %s', $plugin_id, LayoutDefinition::class));
    }

    // Add the module or theme path to the 'path'.     $provider = $definition->getProvider();
    if ($this->moduleHandler->moduleExists($provider)) {
      $base_path = $this->moduleHandler->getModule($provider)->getPath();
    }
    elseif ($this->themeHandler->themeExists($provider)) {
      


  /** * Test safeguard against invalid annotations in QueueWorkerManager. */
  public function testQueueWorkerManagerSafeguard(): void {
    $queue_worker_manager = $this->container->get('plugin.manager.queue_worker');
    $plugin_id = 'test_plugin_id';

    // Ensure if no cron annotation is provided, none is added.     $definition = [];
    $queue_worker_manager->processDefinition($definition$plugin_id);
    $this->assertArrayNotHasKey('cron', $definition);

    // Ensure if an empty cron annotation is provided, the default lease time is     // added.     $definition = ['cron' => []];
    $queue_worker_manager->processDefinition($definition$plugin_id);
    $this->assertArrayHasKey('time', $definition['cron']);
    $this->assertEquals(QueueWorkerManagerInterface::DEFAULT_QUEUE_CRON_TIME, $definition['cron']['time']);

    // Ensure if an invalid lease time (less-than 1 second) is provided, it is     // overridden with the default lease time.
$yaml_discovery = new YamlDiscovery('links.contextual', $this->moduleHandler->getModuleDirectories());
      $yaml_discovery->addTranslatableProperty('title', 'title_context');
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery);
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    // If there is no route name, this is a broken definition.     if (empty($definition['route_name'])) {
      throw new PluginException(sprintf('Contextual link plugin (%s) definition must include "route_name".', $plugin_id));
    }
    // If there is no group name, this is a broken definition.     if (empty($definition['group'])) {
      throw new PluginException(sprintf('Contextual link plugin (%s) definition must include "group".', $plugin_id));
    }
  }

  

  public function testProcessDefinition() {
    $apple = $this->prophesize(EntityTypeInterface::class);
    $this->setUpEntityTypeDefinitions(['apple' => $apple]);

    $apple->getLinkTemplates()->willReturn(['canonical' => 'path/to/apple']);

    $definition = $apple->reveal();
    $this->expectException(InvalidLinkTemplateException::class);
    $this->expectExceptionMessage("Link template 'canonical' for entity type 'apple' must start with a leading slash, the current link template is 'path/to/apple'");
    $this->entityTypeManager->processDefinition($definition, 'apple');
  }

  /** * Tests the getDefinition() method. * * @covers ::getDefinition * * @dataProvider providerTestGetDefinition */
  public function testGetDefinition($entity_type_id$expected) {
    $entity = $this->prophesize(EntityTypeInterface::class);

    
$yaml_discovery = new YamlDiscovery('links.task', $this->moduleHandler->getModuleDirectories());
      $yaml_discovery->addTranslatableProperty('title', 'title_context');
      $this->discovery = new ContainerDerivativeDiscoveryDecorator($yaml_discovery);
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);
    // If there is no route name, this is a broken definition.     if (empty($definition['route_name'])) {
      throw new PluginException(sprintf('Plugin (%s) definition must include "route_name"', $plugin_id));
    }
  }

  /** * {@inheritdoc} */
  public function getTitle(LocalTaskInterface $local_task) {
    $controller = [$local_task, 'getTitle'];
    
return $plugin_id;
        }
      }
    }
    throw new PluginNotFoundException($field_type);
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    foreach (['core', 'source_module', 'destination_module'] as $required_property) {
      if (empty($definition[$required_property])) {
        throw new BadPluginDefinitionException($plugin_id$required_property);
      }
    }
  }

  /** * {@inheritdoc} */
  

  public function createFieldItem(FieldItemListInterface $items$index$values = NULL) {
    // Leverage prototyping of the Typed Data API for fast instantiation.     return $this->typedDataManager->getPropertyInstance($items$index$values);
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);
    if (!isset($definition['list_class'])) {
      $definition['list_class'] = '\Drupal\Core\Field\FieldItemList';
    }

    // Ensure that every field type has a category.     if (empty($definition['category'])) {
      $definition['category'] = $this->t('General');
    }
  }

  /** * {@inheritdoc} */

  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);
    });
  }

}
// If this exception is thrown for a derived CKEditor 5 plugin definition,       // it means the deriver did not generate a valid plugin definition.       // Re-throw the exception, but tweak the language for DX: clarify it is       // for a derived plugin definition.       if ($is_derived) {
        throw new InvalidPluginDefinitionException($e->getPluginId()str_replace('plugin definition', 'derived plugin definition', $e->getMessage()));
      }
      // Otherwise, the exception was appropriate: re-throw it.       throw $e;
    }

    parent::processDefinition($definition$plugin_id);
  }

  /** * {@inheritdoc} */
  public function getPlugin(string $plugin_id, ?EditorInterface $editor): CKEditor5PluginInterface {
    $configuration = $editor
      ? self::getPluginConfiguration($editor$plugin_id)
      : [];
    return $this->createInstance($plugin_id$configuration);
  }

  
throw new InvalidArgumentException(sprintf('Autoconfigured instanceof for type "%s" defines arguments but these are not supported and should be removed.', $interface));
            }
        }

        $tagsToKeep = [];

        if ($container->hasParameter('container.behavior_describing_tags')) {
            $tagsToKeep = $container->getParameter('container.behavior_describing_tags');
        }

        foreach ($container->getDefinitions() as $id => $definition) {
            $container->setDefinition($id$this->processDefinition($container$id$definition$tagsToKeep));
        }

        if ($container->hasParameter('container.behavior_describing_tags')) {
            $container->getParameterBag()->remove('container.behavior_describing_tags');
        }
    }

    private function processDefinition(ContainerBuilder $container, string $id, Definition $definition, array $tagsToKeep): Definition
    {
        $instanceofConditionals = $definition->getInstanceofConditionals();
        $autoconfiguredInstanceof = $definition->isAutoconfigured() ? $container->getAutoconfiguredInstanceof() : [];
        
$this->discovery = new AnnotatedClassDiscovery('Entity', $namespaces, 'Drupal\Core\Entity\Annotation\EntityType');
    $this->stringTranslation = $string_translation;
    $this->classResolver = $class_resolver;
    $this->entityLastInstalledSchemaRepository = $entity_last_installed_schema_repository;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    /** @var \Drupal\Core\Entity\EntityTypeInterface $definition */
    parent::processDefinition($definition$plugin_id);

    // All link templates must have a leading slash.     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} */
$mappers[$id]->setRouteCollection($collection);
      }
    }

    return $mappers;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    parent::processDefinition($definition$plugin_id);

    if (!isset($definition['base_route_name'])) {
      throw new InvalidPluginDefinitionException($plugin_id, "The plugin definition of the mapper '$plugin_id' does not contain a base_route_name.");
    }
  }

  /** * {@inheritdoc} */
  public function buildDataDefinition(array $definition$value = NULL, $name = NULL, $parent = NULL) {
    return $this->typedConfigManager->buildDataDefinition($definition$value$name$parent);
  }
Home | Imprint | This part of the site doesn't use cookies.