Created
July 4, 2020 15:55
-
-
Save pReya/8abb5015f9d00b368a2ccf91e71e610e to your computer and use it in GitHub Desktop.
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
<?php | |
declare(strict_types=1); | |
namespace OCA\SendWelcomeMail\AppInfo; | |
use OCP\AppFramework\App; | |
use OCP\User\Events\UserCreatedEvent; | |
use OCA\SendWelcomeMail\Listener\UserCreatedEventListener; | |
use OCP\EventDispatcher\IEventDispatcher; | |
class Application extends App | |
{ | |
public function __construct() | |
{ | |
parent::__construct('sendwelcomemail'); | |
$container = $this->getContainer(); | |
/* @var IEventDispatcher $eventDispatcher */ | |
$dispatcher = $container->query(IEventDispatcher::class); | |
$dispatcher->addServiceListener(UserCreatedEvent::class, UserCreatedEventListener::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
<?php | |
namespace OCA\SendWelcomeMail\Listener; | |
use OCP\User\Events\UserCreatedEvent; | |
use OCP\EventDispatcher\Event; | |
use OCP\EventDispatcher\IEventListener; | |
class UserCreatedEventListener implements IEventListener | |
{ | |
public function __construct() | |
{ | |
echo("HELLO TEST"); | |
$this->logger->error("HELLO SERVICE!"); | |
throw new \Exception("HELLO SERVICE"); | |
} | |
public function handle(Event $event): void | |
{ | |
if (!($event instanceof UserCreatedEvent)) { | |
return; | |
} | |
$this->logger->error("HELLO SERVICE!"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment