-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgraded to minimal v0.2.1, events and logger, updated demo and docs
- Loading branch information
Showing
13 changed files
with
225 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/** @var \Maduser\Minimal\Routing\Router $router */ | ||
|
||
use App\Demo\Events\SubscriberA; | ||
use App\Demo\Events\SubscriberB; | ||
use Maduser\Minimal\Framework\Facades\Event; | ||
|
||
$router->group([ | ||
'middlewares' => [] | ||
], function() use ($router) { | ||
|
||
$router->get('events', function() { | ||
Event::dispatch('event.a', 'Some message'); | ||
Event::dispatch('event.b', ['some' => 'data']); | ||
Event::dispatch('event.c'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?php | ||
|
||
return [ | ||
\App\Demo\Events\SubscriberA::class, | ||
\App\Demo\Events\SubscriberB::class, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php namespace App\Demo\Events; | ||
|
||
use Maduser\Minimal\Event; | ||
use Maduser\Minimal\Event\Subscriber; | ||
|
||
class SubscriberA extends Subscriber | ||
{ | ||
protected $events = [ | ||
'event.a' => 'respondToEventA', | ||
'event.b' => 'respondToEventB' | ||
]; | ||
|
||
public function respondToEventA($data) | ||
{ | ||
show('SubscriberA responding to event.a'); | ||
show($data); | ||
} | ||
|
||
public function respondToEventB($data) | ||
{ | ||
show('SubscriberA responding to event.b'); | ||
show($data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace App\Demo\Events; | ||
|
||
use Maduser\Minimal\Event\Subscriber; | ||
|
||
class SubscriberB extends Subscriber | ||
{ | ||
protected $events = [ | ||
'event.b' => [ | ||
'respondToEventB1', | ||
'respondToEventB2', | ||
], | ||
'event.c' => [ | ||
'respondToEventC', | ||
] | ||
]; | ||
|
||
public function respondToEventB1() | ||
{ | ||
show('SubscriberB responding to event.b (B1)'); | ||
} | ||
|
||
public function respondToEventB2() | ||
{ | ||
show('SubscriberB responding to event.b (B2)'); | ||
} | ||
|
||
public function respondToEventC() | ||
{ | ||
show('SubscriberB responding to event.c'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
namespace App\Demo\Events; | ||
|
||
use Maduser\Minimal\Event\Subscriber; | ||
|
||
class SystemSubscriber extends Subscriber | ||
{ | ||
protected $events = [ | ||
'app.ready' => 'onAppReady', | ||
'app.routed' => 'onAppRouted', | ||
'app.frontController.dispatch' => 'onFrontControllerDispatch', | ||
'app.frontController.dispatched' => 'onFrontControllerDispatched', | ||
'app.respond' => 'onAppRespond', | ||
'app.responded' => 'onAppResponded', | ||
'app.terminate' => 'onAppTerminate', | ||
'app.terminated' => 'onAppTerminated', | ||
]; | ||
|
||
public function onAppReady() | ||
{ | ||
show($this->interval() . ' - App is ready'); | ||
} | ||
|
||
public function onAppRouted() | ||
{ | ||
show($this->interval() . ' - App is routed'); | ||
} | ||
|
||
public function onFrontControllerDispatch() | ||
{ | ||
show($this->interval() . ' - App is about to dispatch the FrontController'); | ||
} | ||
|
||
public function onFrontControllerDispatched() | ||
{ | ||
show($this->interval() . ' - App has dispatched the FrontController'); | ||
} | ||
|
||
public function onAppRespond() | ||
{ | ||
show($this->interval() . ' - App is about to respond'); | ||
} | ||
|
||
public function onAppResponded() | ||
{ | ||
show($this->interval() . ' - App has responded'); | ||
} | ||
|
||
public function onAppTerminate() | ||
{ | ||
show($this->interval() . ' - App is about to terminate'); | ||
} | ||
|
||
public function onAppTerminated() | ||
{ | ||
show($this->interval() . ' - App is terminating'); | ||
} | ||
|
||
protected function interval() | ||
{ | ||
return microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/** @var \Maduser\Minimal\Routing\Router $router */ | ||
|
||
use Maduser\Minimal\Framework\Events\Subscribers\SystemLog; | ||
use Maduser\Minimal\Framework\Facades\Event; | ||
use Maduser\Minimal\Framework\Facades\Log; | ||
|
||
$router->group([ | ||
'middlewares' => [] | ||
], function() use ($router) { | ||
|
||
$router->get('logger', function() { | ||
Log::info('Hello'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?php | ||
|
||
use Maduser\Minimal\Framework\Events\Subscribers\SystemLog; | ||
|
||
return [ | ||
SystemLog::class | ||
]; |
File renamed without changes.