You've already forked Php-Template
feat: add event dispatcher destructor and implement subscriber interface with tests (#23)
Some checks failed
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Failing after 2m2s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Failing after 1m52s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 1m58s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m30s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m29s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m24s
Some checks failed
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Failing after 2m2s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Failing after 1m52s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Failing after 1m58s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 2m30s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m29s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 2m24s
Reviewed-on: #23 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
This commit was merged in pull request #23.
This commit is contained in:
@@ -45,6 +45,16 @@ class Dispatcher implements DispatcherContract, Arrayable
|
||||
$this->registerListeners();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
foreach ($this->pushed as $event => $payload) {
|
||||
$this->dispatch($event, $payload);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register event listeners based on the ListensFor attribute.
|
||||
*
|
||||
|
||||
15
src/Events/Subscribers/Subscriber.php
Normal file
15
src/Events/Subscribers/Subscriber.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Events\Subscribers;
|
||||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
|
||||
abstract class Subscriber implements SubscriberInterface, Arrayable
|
||||
{
|
||||
public function toArray(): array
|
||||
{
|
||||
return get_object_vars($this);
|
||||
}
|
||||
}
|
||||
10
src/Events/Subscribers/SubscriberInterface.php
Normal file
10
src/Events/Subscribers/SubscriberInterface.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Siteworxpro\App\Events\Subscribers;
|
||||
|
||||
interface SubscriberInterface
|
||||
{
|
||||
public function handle(string $eventName, mixed $payload): mixed;
|
||||
}
|
||||
Reference in New Issue
Block a user