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, ])); }