Changed Plugin Class to Interface! (Final)
-> static methods for Name, Version, Author, Description
This commit is contained in:
@ -5,39 +5,50 @@ namespace ManiaControl\Plugins;
|
||||
use ManiaControl\ManiaControl;
|
||||
|
||||
/**
|
||||
* Plugin parent class
|
||||
* Interface for ManiaControl Plugins
|
||||
*
|
||||
* @author steeffeen & kremsy
|
||||
*/
|
||||
abstract class Plugin {
|
||||
interface Plugin {
|
||||
/**
|
||||
* Plugin Metadata
|
||||
* Constants
|
||||
*/
|
||||
public static $name = 'undefined';
|
||||
public static $version = 'undefined';
|
||||
public static $author = 'undefined';
|
||||
public static $description = 'undefined';
|
||||
|
||||
/**
|
||||
* Protected properties
|
||||
*/
|
||||
protected $maniaControl = null;
|
||||
const PLUGIN_INTERFACE = __CLASS__;
|
||||
|
||||
/**
|
||||
* Create a new plugin
|
||||
*
|
||||
* @param \ManiaControl\ManiaControl $maniaControl
|
||||
*/
|
||||
public abstract function __construct(ManiaControl $maniaControl);
|
||||
public function __construct(ManiaControl $maniaControl);
|
||||
|
||||
/**
|
||||
* Get class name as string
|
||||
* Get Plugin Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static final function getClass() {
|
||||
return __CLASS__;
|
||||
}
|
||||
public static function getName();
|
||||
|
||||
/**
|
||||
* Get Plugin Version
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public static function getVersion();
|
||||
|
||||
/**
|
||||
* Get Plugin Author
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getAuthor();
|
||||
|
||||
/**
|
||||
* Get Plugin Description
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDescription();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -150,7 +150,7 @@ class PluginManager {
|
||||
$classesAfter = get_declared_classes();
|
||||
$newClasses = array_diff($classesAfter, $classesBefore);
|
||||
foreach ($newClasses as $className) {
|
||||
if (!is_subclass_of($className, Plugin::getClass())) {
|
||||
if (!in_array(Plugin::PLUGIN_INTERFACE, class_implements($className))) {
|
||||
continue;
|
||||
}
|
||||
array_push($this->pluginClasses, $className);
|
||||
|
Reference in New Issue
Block a user