register multiple commands at once

This commit is contained in:
Steffen Schröder 2014-01-06 18:32:36 +01:00
parent ae8dc2aed5
commit 012db8d8f4

View File

@ -41,6 +41,15 @@ class CommandManager implements CallbackListener {
* @return bool * @return bool
*/ */
public function registerCommandListener($commandName, CommandListener $listener, $method, $adminCommand = false) { public function registerCommandListener($commandName, CommandListener $listener, $method, $adminCommand = false) {
if (is_array($commandName)) {
$success = true;
foreach ($commandName as $command) {
if (!$this->registerCommandListener($command, $listener, $method, $adminCommand)) {
$success = false;
}
}
return $success;
}
$command = strtolower($commandName); $command = strtolower($commandName);
if (!method_exists($listener, $method)) { if (!method_exists($listener, $method)) {
trigger_error("Given listener can't handle command '{$command}' (no method '{$method}')!"); trigger_error("Given listener can't handle command '{$command}' (no method '{$method}')!");