diff --git a/CHANGELOG.md b/CHANGELOG.md index 537383f..2387ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.1.9 +## 03/14/2022 + +1. [](#new) + * Added support for flex router to return a response instead of a page + # v1.1.8 ## 01/28/2022 diff --git a/blueprints.yaml b/blueprints.yaml index a951a32..efc0158 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Flex Objects slug: flex-objects type: plugin -version: 1.1.8 +version: 1.1.9 description: Flex Objects plugin allows you to manage Flex Objects in Grav Admin. icon: list-alt author: diff --git a/flex-objects.php b/flex-objects.php index 4b77c89..afcd7af 100644 --- a/flex-objects.php +++ b/flex-objects.php @@ -313,6 +313,7 @@ public function onPagesInitialized(Event $event): void $router = $options['router'] ?? null; if (\is_string($router)) { $path = implode('/', array_reverse($path)); + $response = null; $flexEvent = new Event([ 'flex' => $this->grav['flex'], 'parent' => $page, @@ -321,9 +322,14 @@ public function onPagesInitialized(Event $event): void 'path' => $path, 'route' => $route, 'options' => $options, - 'request' => $event['request'] + 'request' => $event['request'], + 'response' => &$response, ]); $flexEvent = $this->grav->fireEvent("flex.router.{$router}", $flexEvent); + if ($response) { + $this->grav->close($response); + } + /** @var PageInterface|null $routedPage */ $routedPage = $flexEvent['page']; if ($routedPage) {