public static function registerDelegates($name)
    {
        $obj = self::getInstance($name);
        $id = self::fetchExtensionID($name);

        if (!$id) {
            return false;
        }

        Symphony::Database()->delete('tbl_extensions_delegates', sprintf("
            `extension_id` = %d ", $id
        ));

        $delegates = $obj->getSubscribedDelegates();

        if (is_array($delegates) && !empty($delegates)) {
            foreach ($delegates as $delegate) {
                Symphony::Database()->insert(
                    array(
                        'extension_id' => $id,
                        'page' => $delegate['page'],
                        'delegate' => $delegate['delegate'],
                        'callback' => $delegate['callback']
                    ),
                    'tbl_extensions_delegates'
                );
            }
        }

        // Remove the unused DB records
        self::cleanupDatabase();

        return $id;
    }