At the moment we're passing a translation message name and set of parameters to Controller::addFlash() when we want to set a flash message. For example:
$this->addFlash('success', ['event-created', $event->getDisplayTitle()]);
In Symfony 4, this second parameter must be a string, not an array (i.e. it enforces what's already recommended), and so the above results in e.g.:
Argument 2 passed to Symfony\Bundle\FrameworkBundle\Controller\Controller::addFlash() must be of the type string, array given, called in grantmetrics/src/AppBundle/Controller/EventController.php on line 72
I think we should:
- Provide Intuition as a service (AppBundle\Service\Translator or something) that can be injected into its current location in the Twig extensions, and also into Controllers where required.
- Create a new common Controller base class that contains our own addFlashMessage($type, $msg, $params) that uses Intuition and passes the already-translated messages to Controller::addFlash().
Does that sound correct?