diff --git a/src/Controller/Component/ApiPaginationComponent.php b/src/Controller/Component/ApiPaginationComponent.php index 8a4b938..34057a8 100644 --- a/src/Controller/Component/ApiPaginationComponent.php +++ b/src/Controller/Component/ApiPaginationComponent.php @@ -59,8 +59,11 @@ public function beforeRender(Event $event) $subject->set($config['key'], $this->pagingInfo); $data = $subject->viewBuilder()->getOption('serialize') ?? []; - $data[] = $config['key']; - $subject->viewBuilder()->setOption('serialize', $data); + + if (is_array($data)) { + $data[] = $config['key']; + $subject->viewBuilder()->setOption('serialize', $data); + } } /**