getDeriver example


  public function getDefinition($plugin_id$exception_on_invalid = TRUE) {
    // This check is only for derivative plugins that have explicitly provided     // an ID. This is not common, and can be expected to fail. Therefore, opt     // out of the thrown exception, which will be handled when checking the     // $base_plugin_id.     $plugin_definition = $this->decorated->getDefinition($plugin_id, FALSE);

    [$base_plugin_id$derivative_id] = $this->decodePluginId($plugin_id);
    $base_plugin_definition = $this->decorated->getDefinition($base_plugin_id$exception_on_invalid);
    if ($base_plugin_definition) {
      $deriver = $this->getDeriver($base_plugin_id$base_plugin_definition);
      if ($deriver) {
        $derivative_plugin_definition = $deriver->getDerivativeDefinition($derivative_id$base_plugin_definition);
        // If a plugin defined itself as a derivative, merge in possible         // defaults from the derivative.         if ($derivative_id && isset($plugin_definition)) {
          $plugin_definition = $this->mergeDerivativeDefinition($plugin_definition$derivative_plugin_definition);
        }
        else {
          $plugin_definition = $derivative_plugin_definition;
        }
      }
    }


  /** * Tests getDeriverClass with classed objects instead of arrays. * * @covers ::getDeriverClass */
  public function testGetDeriverClassWithClassedDefinitions() {
    $definitions = [];
    $definition = $this->prophesize(DerivablePluginDefinitionInterface::class);
    $definition->id()->willReturn('non_container_aware_discovery');
    $definition->getDeriver()->willReturn(TestDerivativeDiscoveryWithObject::class);
    $definitions['non_container_aware_discovery'] = $definition->reveal();

    $this->discoveryMain->expects($this->any())
      ->method('getDefinitions')
      ->willReturn($definitions);

    $discovery = new DerivativeDiscoveryDecorator($this->discoveryMain);
    $definitions = $discovery->getDefinitions();

    // Ensure that both test derivatives got added.     $this->assertContainsOnlyInstancesOf(DerivablePluginDefinitionInterface::class$definitions);
    
Home | Imprint | This part of the site doesn't use cookies.