FilterPluginCollection example


  public function id() {
    return $this->format;
  }

  /** * {@inheritdoc} */
  public function filters($instance_id = NULL) {
    if (!isset($this->filterCollection)) {
      $this->filterCollection = new FilterPluginCollection(\Drupal::service('plugin.manager.filter')$this->filters);
      $this->filterCollection->sort();
    }
    if (isset($instance_id)) {
      return $this->filterCollection->get($instance_id);
    }
    return $this->filterCollection;
  }

  /** * {@inheritdoc} */
  

  protected function processText($text$langcode = LanguageInterface::LANGCODE_NOT_SPECIFIED, array $filter_ids = ['media_embed']) {
    $manager = $this->container->get('plugin.manager.filter');
    $bag = new FilterPluginCollection($manager[]);
    $filters = [];
    foreach ($filter_ids as $filter_id) {
      $filters[] = $bag->get($filter_id);
    }

    $render_context = new RenderContext();
    /** @var \Drupal\filter\FilterProcessResult $filter_result */
    $filter_result = $this->container->get('renderer')->executeInRenderContext($render_contextfunction D) use ($text$filters$langcode) {
      $metadata = new BubbleableMetadata();
      foreach ($filters as $filter) {
        /** @var \Drupal\filter\FilterProcessResult $result */
        
/** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(['system']);
    $this->installEntitySchema('file');
    $this->installSchema('file', ['file_usage']);

    $manager = $this->container->get('plugin.manager.filter');
    $bag = new FilterPluginCollection($manager[]);
    $this->filters = $bag->getAll();
  }

  /** * Tests the editor file reference filter. */
  public function testEditorFileReferenceFilter() {
    $filter = $this->filters['editor_file_reference'];

    $test = function D$input) use ($filter) {
      return $filter->process($input, 'und');
    };
// Enable Twig debugging.     $parameters = $container->getParameter('twig.config');
    $parameters['debug'] = TRUE;
    $container->setParameter('twig.config', $parameters);
  }

  /** * Tests the caption filter with Twig debugging on. */
  public function testCaptionFilter() {
    $manager = $this->container->get('plugin.manager.filter');
    $bag = new FilterPluginCollection($manager[]);
    $filter = $bag->get('filter_caption');

    $renderer = $this->container->get('renderer');

    $test = function D$input) use ($filter$renderer) {
      return $renderer->executeInRenderContext(new RenderContext()function D) use ($input$filter) {
        return $filter->process($input, 'und');
      });
    };

    // No data-caption attribute.

  protected $filters;

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();
    $this->installConfig(['system']);

    $manager = $this->container->get('plugin.manager.filter');
    $bag = new FilterPluginCollection($manager[]);
    $this->filters = $bag->getAll();
  }

  /** * Tests the align filter. */
  public function testAlignFilter() {
    $filter = $this->filters['filter_align'];

    $test = function D$input) use ($filter) {
      return $filter->process($input, 'und');
    };
Home | Imprint | This part of the site doesn't use cookies.