public function unregisterPlugin($plugin)
{
if ($plugin instanceof AbstractPlugin) {
// Given a plugin object, find it in the array
$key = array_search($plugin, $this->_plugins, true);
if (false === $key) {
throw new \Exception('Plugin never registered.');
}
unset($this->_plugins[$key]);
} elseif (is_string($plugin)) {
// Given a plugin class, find all plugins of that class and unset them
foreach ($this->_plugins as $key => $_plugin) {
$type = get_class($_plugin);
if ($plugin == $type) {
unset($this->_plugins[$key]);
}
}
}
return $this;
}