From e6375a47017c591925ec0827cc4aa0f9a0fbe43f Mon Sep 17 00:00:00 2001 From: Daniil Gentili Date: Sun, 2 Jun 2019 13:27:16 +0200 Subject: [PATCH] Rename generic loop --- src/danog/MadelineProto/APIFactory.php | 3 +++ .../Generic/{PeriodFetcherLoop.php => GenericLoop.php} | 9 ++++----- src/danog/MadelineProto/Loop/LoopInterface.php | 6 +++++- src/danog/MadelineProto/Loop/ResumableLoopInterface.php | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) rename src/danog/MadelineProto/Loop/Generic/{PeriodFetcherLoop.php => GenericLoop.php} (91%) diff --git a/src/danog/MadelineProto/APIFactory.php b/src/danog/MadelineProto/APIFactory.php index 8accc07d..5cc33cd0 100644 --- a/src/danog/MadelineProto/APIFactory.php +++ b/src/danog/MadelineProto/APIFactory.php @@ -205,6 +205,9 @@ class APIFactory extends AsyncConstruct return $this->API->settings; } + if ($name === 'logger') { + return $this->API->logger; + } return $this->API->storage[$name]; } diff --git a/src/danog/MadelineProto/Loop/Generic/PeriodFetcherLoop.php b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php similarity index 91% rename from src/danog/MadelineProto/Loop/Generic/PeriodFetcherLoop.php rename to src/danog/MadelineProto/Loop/Generic/GenericLoop.php index 4477a40d..87c04225 100644 --- a/src/danog/MadelineProto/Loop/Generic/PeriodFetcherLoop.php +++ b/src/danog/MadelineProto/Loop/Generic/GenericLoop.php @@ -1,6 +1,6 @@ */ -class PeriodicFetcherLoop extends ResumableSignalLoop +class GenericLoop extends ResumableSignalLoop { const STOP = -1; const PAUSE = null; @@ -45,7 +44,7 @@ class PeriodicFetcherLoop extends ResumableSignalLoop public function __construct($API, $callback, $name) { $this->API = $API; - $this->callback = $callback; + $this->callback = $callback->bindTo($this); $this->name = $name; } public function loop() diff --git a/src/danog/MadelineProto/Loop/LoopInterface.php b/src/danog/MadelineProto/Loop/LoopInterface.php index 26b0db05..18c830ef 100644 --- a/src/danog/MadelineProto/Loop/LoopInterface.php +++ b/src/danog/MadelineProto/Loop/LoopInterface.php @@ -39,6 +39,10 @@ interface LoopInterface */ public function loop(); - + /** + * Get name of the loop + * + * @return string + */ public function __toString(): string; } diff --git a/src/danog/MadelineProto/Loop/ResumableLoopInterface.php b/src/danog/MadelineProto/Loop/ResumableLoopInterface.php index 9950eaee..db689e17 100644 --- a/src/danog/MadelineProto/Loop/ResumableLoopInterface.php +++ b/src/danog/MadelineProto/Loop/ResumableLoopInterface.php @@ -30,7 +30,7 @@ interface ResumableLoopInterface extends LoopInterface /** * Pause the loop. * - * @param int $time For how long to pause the loop + * @param int $time For how long to pause the loop, if null will pause forever (until resume is called from outside of the loop) * * @return Promise */