source class & plugin id in error+exception reports
This commit is contained in:
@ -77,6 +77,50 @@ class PluginManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Plugin Id if the given Class is a Plugin
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @return int
|
||||
*/
|
||||
public static function getPluginId($pluginClass) {
|
||||
if (self::isPluginClass($pluginClass)) {
|
||||
/** @var Plugin $pluginClass */
|
||||
return $pluginClass::getId();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given class implements the plugin interface
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPluginClass($pluginClass) {
|
||||
$pluginClass = self::getClass($pluginClass);
|
||||
if (!class_exists($pluginClass, false)) {
|
||||
return false;
|
||||
}
|
||||
if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($pluginClass, false))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Class of the Object
|
||||
*
|
||||
* @param mixed $object
|
||||
* @return string
|
||||
*/
|
||||
private static function getClass($object) {
|
||||
if (is_object($object)) {
|
||||
return get_class($object);
|
||||
}
|
||||
return (string)$object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate the Plugin with the given Class
|
||||
*
|
||||
@ -133,36 +177,6 @@ class PluginManager {
|
||||
return $pluginClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Class of the Object
|
||||
*
|
||||
* @param mixed $object
|
||||
* @return string
|
||||
*/
|
||||
private static function getClass($object) {
|
||||
if (is_object($object)) {
|
||||
return get_class($object);
|
||||
}
|
||||
return (string)$object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given class implements the plugin interface
|
||||
*
|
||||
* @param string $pluginClass
|
||||
* @return bool
|
||||
*/
|
||||
public static function isPluginClass($pluginClass) {
|
||||
$pluginClass = self::getClass($pluginClass);
|
||||
if (!class_exists($pluginClass, false)) {
|
||||
return false;
|
||||
}
|
||||
if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($pluginClass, false))) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the Plugin is currently running
|
||||
*
|
||||
|
Reference in New Issue
Block a user