mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
Add vizualisation of public views in the workflow history
This commit is contained in:
@@ -183,8 +183,45 @@ class EntityWorkflowSend implements TrackCreationInterface
|
||||
return $this->views->count() > 0;
|
||||
}
|
||||
|
||||
public function isExpired(\DateTimeImmutable $now): bool
|
||||
public function isExpired(?\DateTimeImmutable $now = null): bool
|
||||
{
|
||||
return $now >= $this->expireAt;
|
||||
return ($now ?? new \DateTimeImmutable('now')) >= $this->expireAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the most recent view.
|
||||
*
|
||||
* @return EntityWorkflowSendView|null returns the last view or null if there are no views
|
||||
*/
|
||||
public function getLastView(): ?EntityWorkflowSendView
|
||||
{
|
||||
$last = null;
|
||||
foreach ($this->views as $view) {
|
||||
if (null === $last) {
|
||||
$last = $view;
|
||||
} else {
|
||||
if ($view->getViewAt() > $last->getViewAt()) {
|
||||
$last = $view;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $last;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves an array of views grouped by their remote IP address.
|
||||
*
|
||||
* @return array<string, list<EntityWorkflowSendView>> an associative array where the keys are IP addresses and the values are arrays of views associated with those IPs
|
||||
*/
|
||||
public function getViewsByIp(): array
|
||||
{
|
||||
$views = [];
|
||||
|
||||
foreach ($this->getViews() as $view) {
|
||||
$views[$view->getRemoteIp()][] = $view;
|
||||
}
|
||||
|
||||
return $views;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user