Avoid usage of constants within the bootstrap_modal_messages.module file

Created on 26 April 2023, about 1 year ago

Problem/Motivation

The module defines constants on the root level of the module.

The issue is that it also makes use of the t function:

define('BOOTSTRAP_MODAL_MESSAGES_HEADER', '<h4 class="modal-title">' . t('Messages') . '</h4>');

Which causes issues with scanners such as phpstan to fail with an error because Drupal has not been properly bootstrapped at that point.

Fatal error: Drupal\Core\DependencyInjection\ContainerNotInitializedException thrown while calling __toString on a Drupal\Core\StringTranslation\TranslatableMarkup object in /app/application/web/core/lib/Drupal.php on line 179: \Drupal::$container is not initialized yet. \Drupal::setContainer() must be called with a real container. in /app/application/web/core/lib/Drupal/Component/Utility/ToStringTrait.php on line 20

Steps to reproduce

Attempt to scan the module with phpstan.

Proposed resolution

Remove the constant declarations and move the values directly into the functions which requires them.

Remaining tasks

User interface changes

N/A

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

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

Comments & Activities

Production build 0.69.0 2024