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
Comments
Comment #3
murzCreated a MR with the fix, please review.
Comment #5
mably commentedThanks for the fix!
If there is anything we can add to this module, feel free to share.
Comment #7
murzSuch a quick merge, thanks! Updated the contribution record.