Skip to content

Instantly share code, notes, and snippets.

@SamMousa
Last active January 12, 2018 07:50
Show Gist options
  • Save SamMousa/1efbe706efc93a3797892cd6243bf982 to your computer and use it in GitHub Desktop.
Save SamMousa/1efbe706efc93a3797892cd6243bf982 to your computer and use it in GitHub Desktop.
<?php
class EventHandler.php {
private $handlerClass;
public function __construct(string $handlerClass) {
$this->handlerClass = $handlerClass
}
public function __invoke(... $args) {
$instance = new {$this->handlerClass};
$instance->handle(... $args);
}
}
// Usage
$config = [
'on afterLogin' => new EventHandler(AfterLoginHandler::class)
]
@SamMousa
Copy link
Author

Note this is pseudo code :)

@markusnovelt
Copy link

And EventHandlerInterface? ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment