-
-
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.
- Loading branch information
Showing
5 changed files
with
116 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Clivern/Walnut project. | ||
* (c) Clivern <hello@clivern.com> | ||
*/ | ||
|
||
namespace App\Event; | ||
|
||
use App\Entity\Event; | ||
use Symfony\Contracts\EventDispatcher\Event as SymfonyEvent; | ||
|
||
/** | ||
* AuditAction Class. | ||
*/ | ||
class AuditAction extends SymfonyEvent | ||
{ | ||
public const NAME = 'audit.action'; | ||
|
||
/** @var Event */ | ||
protected $event; | ||
|
||
/** | ||
* Class Constructor. | ||
*/ | ||
public function __construct(Event $event) | ||
{ | ||
$this->event = $event; | ||
} | ||
|
||
/** | ||
* Get Event Instance. | ||
*/ | ||
public function getEvent(): Event | ||
{ | ||
return $this->event; | ||
} | ||
} |
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,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the Clivern/Walnut project. | ||
* (c) Clivern <hello@clivern.com> | ||
*/ | ||
|
||
namespace App\EventSubscriber; | ||
|
||
use App\Event\AuditAction; | ||
use Psr\Log\LoggerInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* AuditActionSubscriber Class. | ||
*/ | ||
class AuditActionSubscriber implements EventSubscriberInterface | ||
{ | ||
/** @var LoggerInterface */ | ||
private $logger; | ||
|
||
/** | ||
* Class Constructor. | ||
*/ | ||
public function __construct( | ||
LoggerInterface $logger | ||
) { | ||
$this->logger = $logger; | ||
} | ||
|
||
/** | ||
* Event Created Handler. | ||
*/ | ||
public function onAuditAction(AuditAction $action) | ||
{ | ||
$this->logger->info(sprintf( | ||
'Event with type %s created with ID %d, UUID %s', | ||
$action->getEvent()->getType(), | ||
$action->getEvent()->getId(), | ||
$action->getEvent()->getUUID() | ||
)); | ||
} | ||
|
||
/** | ||
* Get Subscribed Events. | ||
* | ||
* @return array | ||
*/ | ||
public static function getSubscribedEvents() | ||
{ | ||
return [ | ||
AuditAction::NAME => 'onAuditAction', | ||
]; | ||
} | ||
} |
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