Skip to content

Commit

Permalink
Update SyncListener.php
Browse files Browse the repository at this point in the history
  • Loading branch information
adrolli committed Sep 4, 2024
1 parent a4e39ed commit 1be07c1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/sync/src/Listener/SyncListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,23 @@ protected function handleModelEvent($model, $eventType)
'platform' => $this->currentPlatform->id,
]);

$modelData = $model->toArray();

// If this is a WordPress user model, include all meta data
if ($model instanceof \Moox\Press\Models\WpUser) {
$userMeta = $model->metas()->get()->pluck('meta_value', 'meta_key')->toArray();

Check failure on line 102 in packages/sync/src/Listener/SyncListener.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined method Moox\Press\Models\WpUser::metas().
$modelData = array_merge($modelData, $userMeta);
}

$syncData = [
'event_type' => $eventType,
'model' => $model->toArray(),
'model' => $modelData,
'model_class' => get_class($model),
'platform' => $this->currentPlatform->toArray(),
];

$this->logDebug('Sync data prepared', ['sync_data' => $syncData]);

$this->invokeWebhooks($syncData);
}

Expand Down

0 comments on commit 1be07c1

Please sign in to comment.