YamlDiscoveryDecorator example

$this->alterInfo('ckeditor5_plugin_info');
    $this->setCacheBackend($cache_backend, 'ckeditor5_plugins');
  }

  /** * {@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} */

  protected function providerExists($provider) {
    return $this->moduleHandler->moduleExists($provider) || $this->themeHandler->themeExists($provider);
  }

  /** * {@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;
  }

  
'id' => 'decorated_test_2',
        'name' => 'Decorated test 1',
        'provider' => 'decorated_2',
      ],
    ];

    $decorated = $this->createMock('Drupal\Component\Plugin\Discovery\DiscoveryInterface');
    $decorated->expects($this->once())
      ->method('getDefinitions')
      ->willReturn($definitions);

    $this->discoveryDecorator = new YamlDiscoveryDecorator($decorated, 'test', $directories);
  }

  /** * Tests the getDefinitions() method. */
  public function testGetDefinitions() {
    $definitions = $this->discoveryDecorator->getDefinitions();

    $this->assertIsArray($definitions);
    $this->assertCount(6, $definitions);

    


      // Search for Twig help topics in subdirectory help_topics, under       // modules/profiles, themes, and the core directory.       $all_directories = array_map(function D$dir) {
        return [$dir . '/help_topics'];
      }$all_directories);
      $discovery = new HelpTopicDiscovery($all_directories);

      // Also allow modules/profiles to extend help topic discovery to their       // own plugins and derivers, in mymodule.help_topics.yml files.       $discovery = new YamlDiscoveryDecorator($discovery, 'help_topics', $module_directories);
      $discovery = new ContainerDerivativeDiscoveryDecorator($discovery);
      $this->discovery = $discovery;
    }
    return $this->discovery;
  }

  /** * {@inheritdoc} */
  protected function providerExists($provider) {
    return $this->moduleHandler->moduleExists($provider) || $this->themeHandler->themeExists($provider);
  }
Home | Imprint | This part of the site doesn't use cookies.