The getRootPageFromUrl
hook is triggered when searching the current root page.
It does not pass any parameters and expects a \Contao\PageModel
instance as return
value or null.
Return a \Contao\PageModel
instance if you want to override the default method
for searching the root page.
// src/EventListener/GetRootPageFromUrlListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('getRootPageFromUrl')]
class GetRootPageFromUrlListener
{
public function __invoke(): ?\Contao\PageModel
{
// Do something …
}
}