private function getReferrerUrl(EnvironmentInterface $environment)
    {
        $parent = $environment->getParentDataDefinition();
        $event  = new GetReferrerEvent(
            true,
            (null !== $parent)
                ? $parent->getName()
                : $environment->getDataDefinition()->getName()
        );

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

        return $event->getReferrerUrl();
    }