Remove 'final' from Barcodes FieldFormatter Class

Created on 25 September 2024, 3 months ago

Problem/Motivation

I have a specific use case with a decoupled website that uses seperate domains for the frontend vs backend of the site. Problematically, when rendering links as a barcode, it is not possible to perform the required rewriting needed in a preprocess function nor in a template, as the barcode processing happpens already in the FieldFormatter. I'd like to be able to prepend the correct domain path PRIOR to the generation of the barcode and I've found this is best done by extending the Barcode FieldFormatter. Problematically, when I do this, I see a fatal error because for some reason the Barcode class id declared as 'final'. I don't see other contrib module FieldFormatters delcaring their FieldFormatter class as 'final', so I'm curious if there's a reason this is done and what the motivation is.

Steps to reproduce

Enable the barcodes module and create a custom module with a FieldFormatter class that extends the Barcode FieldFormatter class. Add custom logic to process a compatible field, enable your module, set your field to use your custom FieldFormatter for its display. Attempt to view content with a populate field that should render with your custom FieldFormatter. You should see a fatal error that states "cannot extend final class Drupal\barcodes\Plugin\Field\FieldFormatter\Barcode"

Proposed resolution

Remove 'final' from the Barcode Class.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States brooke_heaton

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

Comments & Activities

Production build 0.71.5 2024