public function register($plugin, $name = null)
    {
        if ($plugin instanceof Plugin) {
            $key = $plugin->getKey();
            $p = $plugin;
        } else {
            if (!$name) {
                throw new Exception(t('You must specify a plugin key and name.'));
            }
            $key = $plugin;
            $p = new Plugin();
            $p->setKey($key);
            $p->setName($name);
        }
        $this->plugins[$key] = $p;
    }