public static function redirectHome(EnvironmentInterface $environment)
    {
        $input = $environment->getInputProvider();

        if ($input->hasParameter('table') && ($hasParentId = $input->hasParameter('pid'))) {
            if ($hasParentId) {
                $event = new RedirectEvent(
                    \sprintf(
                        'contao?do=%s&table=%s&pid=%s',
                        $input->getParameter('do'),
                        $input->getParameter('table'),
                        $input->getParameter('pid')
                    )
                );
            } else {
                $event = new RedirectEvent(
                    \sprintf(
                        'contao?do=%s&table=%s',
                        $input->getParameter('do'),
                        $input->getParameter('table')
                    )
                );
            }
        } else {
            $event = new RedirectEvent(
                \sprintf(
                    'contao?do=%s',
                    $input->getParameter('do')
                )
            );
        }

        $environment->getEventDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $event);
    }