Allow another module to override the LeafletDefaultFormatter field formatter.

Created on 11 July 2025, 15 days ago

Problem/Motivation

Allow another module to override the LeafletDefaultFormatter field formatter.

If you create a plugin that overrides the formatter, it's impossible to add services, as the class returned is not the one you expect.

Steps to reproduce

Create a new FieldFormatter plugin that override LeafletDefaultFormatter.
Add:

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition);

    $instance->foo= $container->get('foo');

    return $instance;
  }

Proposed resolution

Replace

return new self(...

by

return new static(...

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

10.3

Component

Code

Created by

🇫🇷France damien laguerre

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

Comments & Activities

Production build 0.71.5 2024