Changed Plugin Class to Interface! (Final)

-> static methods for Name, Version, Author, Description
This commit is contained in:
Steffen Schröder
2013-12-03 22:21:17 +01:00
parent 35a7232894
commit 6c247f0519
8 changed files with 247 additions and 63 deletions

View File

@ -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();
}
?>

View File

@ -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);