public function onGenerateAlias($value, DataContainer $dc)
    {
        $autoAlias = false;

        // Generate alias if there is none
        if (!$value) {
            $autoAlias = true;
            $value = StringUtil::generateAlias($dc->activeRecord->frontendTitle ?: $dc->activeRecord->title);
        }

        if (MultilingualHelper::isActive() && $dc instanceof Driver) {
            $exists = $this->db->fetchColumn(
                "SELECT id FROM {$dc->table} WHERE alias=? AND id!=? AND {$dc->getLanguageColumn()}=?",
                [$value, $dc->activeRecord->id, $dc->getCurrentLanguage()]
            );
        } else {
            $exists = $this->db->fetchColumn(
                "SELECT id FROM {$dc->table} WHERE alias=? AND id!=?",
                [$value, $dc->activeRecord->id]
            );
        }

        // Check whether the category alias exists
        if ($exists) {
            if ($autoAlias) {
                $value .= '-'.$dc->activeRecord->id;
            } else {
                throw new \RuntimeException(\sprintf($GLOBALS['TL_LANG']['ERR']['aliasExists'], $value));
            }
        }

        return $value;
    }