AnnotationBridgeDecorator example

/** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!$this->discovery) {
      $discovery = new AnnotatedClassDiscovery($this->subdir, $this->namespaces, $this->pluginDefinitionAnnotationName, $this->additionalAnnotationNamespaces);
      $discovery = new YamlDiscoveryDecorator($discovery, 'layouts', $this->moduleHandler->getModuleDirectories() + $this->themeHandler->getThemeDirectories());
      $discovery
        ->addTranslatableProperty('label')
        ->addTranslatableProperty('description')
        ->addTranslatableProperty('category');
      $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);

    
/** * {@inheritdoc} */
  protected function getDiscovery() {
    if (!$this->discovery) {
      $discovery = new AnnotatedClassDiscovery($this->subdir, $this->namespaces, $this->pluginDefinitionAnnotationName, $this->additionalAnnotationNamespaces);
      $discovery = new YamlDiscoveryDecorator($discovery, 'ckeditor5', $this->moduleHandler->getModuleDirectories());
      // Note: adding translatable properties here is impossible because it only       // supports top-level properties.       // @see \Drupal\ckeditor5\Plugin\CKEditor5PluginDefinition::label()       $discovery = new AnnotationBridgeDecorator($discovery$this->pluginDefinitionAnnotationName);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    if (!$definition instanceof CKEditor5PluginDefinition) {
      
/** * @covers ::getDefinitions */
  public function testGetDefinitions() {
    $definitions = [];
    $definitions['object'] = new ObjectDefinition(['id' => 'foo']);
    $definitions['array'] = ['id' => 'bar'];
    $discovery = $this->prophesize(DiscoveryInterface::class);
    $discovery->getDefinitions()->willReturn($definitions);

    $decorator = new AnnotationBridgeDecorator($discovery->reveal(), TestAnnotation::class);

    $expected = [
      'object' => new ObjectDefinition(['id' => 'foo']),
      'array' => new ObjectDefinition(['id' => 'bar']),
    ];
    $this->assertEquals($expected$decorator->getDefinitions());
  }

}

/** * {@inheritdoc} */
Home | Imprint | This part of the site doesn't use cookies.