Unable to use parent functions in the plugins that extend the ViewsFiltersSummary plugin

Created on 25 September 2025, 16 days ago

Problem/Motivation

When I'm trying to extend the module's ViewsFiltersSummary ViewsArea plugin just to override some functions, for example, buildFilterSummaryItem() - this doesn't work, the parent function is called instead of the function in the overridden class.

Steps to reproduce

1. Extend the class like this:

class MUViewsFiltersSummary extends ViewsFiltersSummary {
...
}

2. Override a function like this:

  protected function buildFilterSummaryItem(
    string $id,
    string $label,
    string $value,
    string|int|null $value_raw = NULL,
  ): array {
    $item = parent::buildFilterSummaryItem($id, $label, $value, $value_raw);
    $item['value'] = 'Test';
    return $item;

3. Add this plugin to a view area, and see that this doesn't work.

Proposed resolution

The issue is that the original plugin class uses "self" instead of "static" in the method create():

  /**
   * {@inheritdoc}
   */
  public static function create(
    ContainerInterface $container,
    array $configuration,
    $plugin_id,
    $plugin_definition,
  ) {
    return new self(
      $configuration,
      $plugin_id,
      $plugin_definition,
      $container->get('string_translation'),
      $container->get('entity_type.manager'),
      $container->get('entity_type.bundle.info'),
      $container->get('logger.factory'),
      $container->get('language_manager')
    );
  }

Changing "self" to "static" resolves the issue.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

🇦🇲Armenia murz Yerevan, Armenia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024