Problem/Motivation

Steps to reproduce

1. In Extend, search on "FlipBook". Click the arrow to expand settings. Select Configure.
2. Select either option. Press Submit.
The URL is /admin/config/choosepdfstyle. An error is generated. Refering to the log, you get this message:

Error: Non-static method Drupal\Core\Messenger\MessengerInterface::addMessage() cannot be called statically in Drupal\flipbook\Form\ChoosePdfStyleForm->submitForm() (line 88 of /home/mysite/mysite.org/modules/flipbook/src/Form/ChoosePdfStyleForm.php)
#0 [internal function]: Drupal\flipbook\Form\ChoosePdfStyleForm->submitForm(Array, Object(Drupal\Core\Form\FormState))

Comments

timkroehler created an issue. See original summary.

timkroehler’s picture

Is it possible that the Messenger code needs to be changed to this:

in src/Form/ChoosePDFStyleForm.php, line 88:
//MessengerInterface::addMessage('Changes Saved');
should be:
\Drupal::messenger()->addMessage('Changes Saved');

murugesan velu’s picture

I got the same error when I implement the flipbook module with my project

We need to change the code in src/Form/ChoosePDFStyleForm.php, line 88

MessengerInterface::addMessage('Changes Saved');

to

\Drupal::messenger()->addMessage('Changes Saved');

socialnicheguru’s picture

this fix does work. patch?

socialnicheguru’s picture

Status: Active » Needs review
StatusFileSize
new545 bytes
4kant’s picture

Patch works perfectly. Thanks

oheller’s picture

Status: Needs review » Needs work

The call should be refactored to us dependency injection. Drupal calls should be avoided in classes.

kushal bansal’s picture

Issue Fixed in release 9.1.4

kushal bansal’s picture

Version: 8.x-1.2 » 9.1.4-alpha2
Assigned: Unassigned » kushal bansal
Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.