Allow NotificationSender class to be extended
>>> [!note] Migrated issue <!-- Drupal.org comment --> <!-- Migrated from issue #3554232. --> Reported by: [saidatom](https://www.drupal.org/user/1846674) Related to !19 >>> <h3 id="summary-problem-motivation">Problem/Motivation</h3> <p>The NotificationSender class is currently marked as `final`, which prevents it from being extended by custom implementations. Additionally, the constructor properties are defined as `private readonly`, making them inaccessible to child classes.<br> This prevents projects from customizing the email sending behavior while reusing the existing logic for notification handling, settings retrieval, and user management.</p> <h4 id="summary-steps-reproduce">Steps to reproduce</h4> <p>In our case, we need to send plain text emails instead of HTML emails. Currently, we have to duplicate the entire NotificationSender class (~130 lines) just to override the sendEmailToUsers method.<br> With this change, we can simply extend the base class and override only the sendEmailToUsers method (~30 lines), making the code more maintainable and reducing duplication.</p> <h3 id="summary-proposed-resolution">Proposed resolution</h3> <ol> <li>Remove the `final` keyword from the NotificationSender class</li> <li>Change constructor properties from `private readonly` to `protected readonly`</li> </ol> <p>This would allow projects to extend NotificationSender and override specific methods (like sendEmailToUsers) while inheriting the core functionality.</p> <h3 id="summary-remaining-tasks">Remaining tasks</h3> <h3 id="summary-ui-changes">User interface changes</h3> <h3 id="summary-api-changes">API changes</h3> <h3 id="summary-data-model-changes">Data model changes</h3>
issue