From 02efc2c632db2b9a6c69b85e4466d871163f7976 Mon Sep 17 00:00:00 2001 From: Oli Date: Wed, 6 Jul 2022 16:14:14 +0200 Subject: [PATCH] Fix #165 --- CHANGELOG.md | 3 +++ src/DataEvent.php | 2 +- src/controllers/DefaultController.php | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdfb0be..869e88e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Release Notes for Element API +## Unreleased +- Fix an issue where `EVENT_BEFORE_SEND_DATA` wasn't returning data. ([#165](https://github.com/craftcms/element-api/issues/165)) + ## 3.0.0 - 2022-05-03 ### Added diff --git a/src/DataEvent.php b/src/DataEvent.php index 0052bae..bbf9259 100644 --- a/src/DataEvent.php +++ b/src/DataEvent.php @@ -16,5 +16,5 @@ class DataEvent extends Event /** * @var Scope The Fractal data associated with the event */ - public $data; + public Scope $payload; } diff --git a/src/controllers/DefaultController.php b/src/controllers/DefaultController.php index d89cbe1..7dd6d23 100644 --- a/src/controllers/DefaultController.php +++ b/src/controllers/DefaultController.php @@ -175,7 +175,7 @@ public function actionIndex(string $pattern): Response // Fire a 'beforeSendData' event if ($this->hasEventHandlers(self::EVENT_BEFORE_SEND_DATA)) { $this->trigger(self::EVENT_BEFORE_SEND_DATA, new DataEvent([ - 'data' => $data, + 'payload' => $data, ])); }