From f9d31a00d340add33bc108c089f5036bd2d68bb7 Mon Sep 17 00:00:00 2001 From: Barry <5648875+BarryMode@users.noreply.github.com> Date: Wed, 26 Jul 2017 01:02:52 -0500 Subject: [PATCH] blackhole.php --- blackhole.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 blackhole.php diff --git a/blackhole.php b/blackhole.php new file mode 100644 index 0000000..5dabd99 --- /dev/null +++ b/blackhole.php @@ -0,0 +1,43 @@ + ['onPageInitialized', 0], + 'onOutputRendered' => ['onOutputRendered', 0] + ]; + } + + public function onPageInitialized() { + if (!empty($_GET['pages']) && $_GET['pages'] == 'all') { + ob_start(); + + // get output_path from plugin settings + $output_path = $this->config->get('plugins.blackhole.output_path'); + + // get all routes from grav + $routes = $this->grav['pages']->routes(); + + if (!empty($_GET['output_path'])) { + $this->content = $output_path; + } else { + $this->content = json_encode($routes, JSON_UNESCAPED_SLASHES); + } + } + } + + public function onOutputRendered() { + // publish page routes + if (!empty($_GET['pages']) && $_GET['pages'] == 'all') { + ob_end_clean(); + echo $this->content; + } + } +} \ No newline at end of file