1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-07-28 17:02:04 +03:00

Fixed tests, applied StyleCI changes

This commit is contained in:
Dan Brown
2022-03-26 20:38:03 +00:00
parent 3625f12abe
commit b5281bc9ca
5 changed files with 17 additions and 14 deletions

View File

@ -60,13 +60,13 @@ class WebhookFormatter
/**
* @param callable(string, Model):bool $condition
* @param callable(Model):void $format
* @param callable(Model):void $format
*/
public function addModelFormatter(callable $condition, callable $format): void
{
$this->modelFormatters[] = [
'condition' => $condition,
'format' => $format,
'format' => $format,
];
}
@ -74,14 +74,14 @@ class WebhookFormatter
{
// Load entity owner, creator, updater details
$this->addModelFormatter(
fn($event, $model) => ($model instanceof Entity),
fn($model) => $model->load(['ownedBy', 'createdBy', 'updatedBy'])
fn ($event, $model) => ($model instanceof Entity),
fn ($model) => $model->load(['ownedBy', 'createdBy', 'updatedBy'])
);
// Load revision detail for page update and create events
$this->addModelFormatter(
fn($event, $model) => ($model instanceof Page && ($event === ActivityType::PAGE_CREATE || $event === ActivityType::PAGE_UPDATE)),
fn($model) => $model->load('currentRevision')
fn ($event, $model) => ($model instanceof Page && ($event === ActivityType::PAGE_CREATE || $event === ActivityType::PAGE_UPDATE)),
fn ($model) => $model->load('currentRevision')
);
}
@ -118,6 +118,7 @@ class WebhookFormatter
{
$instance = new static($event, $webhook, $detail, $initiator, $initiatedTime);
$instance->addDefaultModelFormatters();
return $instance;
}
}
}