The Dispatcher class
As seen in the previous reverse engineering example, there are two main tools to manage the controller’s routing: for the legacy FO and BO core classes, it is the Dispatcher
class, and for the Symfony migrated controllers, it is the Symfony router.
As Symfony routing is already well documented on the Symfony website at the following address: https://symfony.com/doc/4.4/routing.html, we will not provide more explanations about it. Even if it is going to sadly disappear once the migration is finished, the Dispatcher
routing class requires more explanation.
Let’s continue the reverse engineering, with the product category front controller already presented at the beginning of the chapter.
We will now focus on the use of Dispatcher::getInstance()->dispatch();
in /
index.php
.
The getInstance()
static function instantiates the Dispatcher
object with the request
information injected as an argument.
The _construct()
method checks whether...