Small Fix + Test

Test/Usage example:

		$this->getShootmaniaScores()->setCallable(function(OnScoresStructure $scores){
			$scores->getUsageInformation();
		});
This commit is contained in:
kremsy 2017-04-07 18:37:08 +02:00
parent 067536458e
commit 5b330d5753
2 changed files with 9 additions and 2 deletions

View File

@ -8,7 +8,13 @@ use ManiaControl\Callbacks\Structures\Common\BaseResponseStructure;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
//TODO test /**
* Class For Invoking Callbacks on Script Methods
*
* @author ManiaControl Team <mail@maniacontrol.com>
* @copyright 2014-2017 ManiaControl Team
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
*/
class InvokeScriptCallback implements CallbackListener, UsageInformationAble { class InvokeScriptCallback implements CallbackListener, UsageInformationAble {
use UsageInformationTrait; use UsageInformationTrait;
@ -40,7 +46,7 @@ class InvokeScriptCallback implements CallbackListener, UsageInformationAble {
*/ */
public function setCallable(callable $function) { public function setCallable(callable $function) {
$this->maniaControl->getCallbackManager()->registerCallbackListener($this->callbackName, $this, function(BaseResponseStructure $callBackData) use (&$function){ $this->maniaControl->getCallbackManager()->registerCallbackListener($this->callbackName, $this, function(BaseResponseStructure $callBackData) use (&$function){
if($callBackData == $this->responseId){ if($callBackData->getResponseId() == $this->responseId){
call_user_func_array($function, array($callBackData)); call_user_func_array($function, array($callBackData));
} }
}); });

View File

@ -3,6 +3,7 @@
namespace ManiaControl\Script; namespace ManiaControl\Script;
use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Callbacks\Structures\ShootMania\OnScoresStructure;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;