Breaking: The view event of the new job form is gone
Description
The new job form no longer dispatches
\FGTCLB\, and the
class is removed.
Every plugin of this extension, the job list and the job detail included,
dispatches
\FGTCLB\ of
academic_base instead, once each time it renders. It is one event
for every academic plugin and carries the same two things the removed one did:
the plugin action context of academic_base and the view. See
ModifyPluginViewEvent,
Feature: The plugins dispatch the plugin view event and the changelog of academic_base.
As before, the form assigns the validations after the event, so a listener cannot replace them.
Impact
A listener of the removed event is no longer called. It causes no error: TYPO3
registers the event of a listener as a class name, read from the type of its
parameter or from the
event
argument of the attribute, without loading
the class, and PHP checks the type of a parameter only when the method is
called. The variables the listener assigned are missing from the form.
PHPStan reports the listener, because the class of its parameter does not exist any more:
Parameter $event of method MyVendor\MySitepackage\EventListener\AddFormHint::__invoke()
has invalid type FGTCLB\AcademicJobs\Event\ModifyJobControllerNewActionViewEvent.
Affected installations
Installations with an event listener of
Modify, registered with an attribute or in
Configuration/Services.yaml. Searching the project code for the class
name finds them.
Migration
Register the listener for
Modify and return early for
every other plugin:
use FGTCLB\AcademicJobs\Event\ModifyJobControllerNewActionViewEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
final class AddFormHint
{
#[AsEventListener]
public function __invoke(ModifyJobControllerNewActionViewEvent $event): void
{
$event->getView()->assign('formHintPageId', 42);
}
}
use FGTCLB\AcademicBase\Event\ModifyPluginViewEvent;
use TYPO3\CMS\Core\Attribute\AsEventListener;
final class AddFormHint
{
#[AsEventListener]
public function __invoke(ModifyPluginViewEvent $event): void
{
$context = $event->getPluginControllerActionContext();
if ($context->getControllerExtensionName() !== 'AcademicJobs'
|| $context->getActionName() !== 'new'
) {
return;
}
$event->getView()->assign('formHintPageId', 42);
}
}