-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from mitydigital/feature/new-events
Support new events
- Loading branch information
Showing
18 changed files
with
445 additions
and
58 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,13 @@ | ||
<?php | ||
|
||
return [ | ||
'glide' => 'Image Cache', | ||
|
||
'license' => 'License', | ||
|
||
'search' => 'Search Index', | ||
|
||
'stache' => 'Content Stache', | ||
|
||
'static' => 'Static Page Cache', | ||
]; |
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 |
---|---|---|
@@ -1,20 +1,30 @@ | ||
<?php | ||
|
||
return [ | ||
'cleared' => 'Cleared', | ||
'created' => 'Created', | ||
|
||
'deleted' => 'Deleted', | ||
|
||
'impersonation_started' => 'Started impersonating', | ||
'impersonation_ended' => 'Ended impersonating', | ||
|
||
'logged_in' => 'Logged In', | ||
'logged_out' => 'Logged Out', | ||
'login_failed' => 'Attempted (but failed) to log in', | ||
|
||
'password_changed' => 'Had their password changed', | ||
'password_reset' => 'Requested a password reset', | ||
|
||
'refreshed' => 'Refreshed', | ||
'replaced' => 'Replaced', | ||
'reuploaded' => 'Re-uploaded', | ||
|
||
'saved' => 'Saved', | ||
'set' => 'Set', | ||
|
||
'updated' => 'Updated', | ||
'uploaded' => 'Uploaded', | ||
|
||
'warmed' => 'Warmed', | ||
]; |
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,5 @@ | ||
<div>{{ $data->impersonator->name }} {{ strtolower($handler->action()) }} {{ $data->impersonated->name }}</div> | ||
<div class="text-xs text-gray-500">{{ __('statamic-logger::listeners.impersonator') }} | ||
: {{ $data->impersonator->id }}</div> | ||
<div class="text-xs text-gray-500">{{ __('statamic-logger::listeners.impersonated') }} | ||
: {{ $data->impersonated->id }}</div> |
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,2 @@ | ||
<div>{{ $data->name }} {{ strtolower($handler->action()) }}</div> | ||
<div class="text-xs text-gray-500">{{ __('statamic-logger::listeners.id') }}: {{ $data->id }}</div> |
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 @@ | ||
<div class="h-10 flex items-center">{{ $data->utility }} {{ strtolower($handler->action()) }}</div> |
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,58 @@ | ||
<?php | ||
|
||
namespace MityDigital\StatamicLogger\Listeners; | ||
|
||
use MityDigital\StatamicLogger\Abstracts\EventListener; | ||
use Statamic\Events\ImpersonationEnded; | ||
use Statamic\Events\ImpersonationStarted; | ||
|
||
class Impersonation extends EventListener | ||
{ | ||
public function view(): string | ||
{ | ||
return 'statamic-logger::listeners.impersonation'; | ||
} | ||
|
||
protected function data($event): array | ||
{ | ||
return [ | ||
'impersonated' => $this->getUser($event->impersonated), | ||
'impersonator' => $this->getUser($event->impersonator), | ||
]; | ||
} | ||
|
||
protected function getUser($user = null): array | ||
{ | ||
if (! $user) { | ||
return [ | ||
'id' => null, | ||
'name' => __('statamic-logger::errors.unknown_user'), | ||
]; | ||
} | ||
|
||
$name = $user->id; | ||
if (method_exists($user, 'name')) { | ||
$name = $user->name(); | ||
} elseif ($user->name) { | ||
$name = $user->name; | ||
} | ||
|
||
return [ | ||
'id' => $user->id, | ||
'name' => $name, | ||
]; | ||
} | ||
|
||
protected function getAuthenticatedUser($event) | ||
{ | ||
return $event->impersonator; | ||
} | ||
|
||
protected function verb($event): string | ||
{ | ||
return match ($event) { | ||
ImpersonationEnded::class => __('statamic-logger::verbs.impersonation_ended'), | ||
ImpersonationStarted::class => __('statamic-logger::verbs.impersonation_started'), | ||
}; | ||
} | ||
} |
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,33 @@ | ||
<?php | ||
|
||
namespace MityDigital\StatamicLogger\Listeners; | ||
|
||
use MityDigital\StatamicLogger\Abstracts\EventListener; | ||
use Statamic\Events\SiteCreated; | ||
use Statamic\Events\SiteDeleted; | ||
use Statamic\Events\SiteSaved; | ||
|
||
class Site extends EventListener | ||
{ | ||
public function view(): string | ||
{ | ||
return 'statamic-logger::listeners.site'; | ||
} | ||
|
||
protected function data($event): array | ||
{ | ||
return [ | ||
'id' => $event->site->handle(), | ||
'name' => $event->site->name(), | ||
]; | ||
} | ||
|
||
protected function verb($event): string | ||
{ | ||
return match ($event) { | ||
SiteCreated::class => __('statamic-logger::verbs.created'), | ||
SiteDeleted::class => __('statamic-logger::verbs.deleted'), | ||
SiteSaved::class => __('statamic-logger::verbs.saved') | ||
}; | ||
} | ||
} |
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
Oops, something went wrong.