private static function getEntityManager(Event $event)
    {
        if (null === self::$em) {
            if (null !== self::getApplication($event)) {
                self::$em = self::getApplication($event)->getEntityManager();
            }
        }

        return self::$em;
    }