Skip to content

Commit

Permalink
⚡ instead of route:before use render:after hook
Browse files Browse the repository at this point in the history
Signed-off-by: bnomei <[email protected]>
  • Loading branch information
bnomei committed Sep 18, 2023
1 parent 94f19b1 commit a455de9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "kirby-plugin",
"description": "Setup performant HTTP Status Code Redirects from within the Kirby Panel",
"homepage": "https://github.com/bnomei/kirby3-redirects",
"version": "1.11.0",
"version": "1.12.0",
"license": "MIT",
"authors": [
{
Expand Down
14 changes: 8 additions & 6 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
'plugin-redirects3xx' => __DIR__ . '/blueprints/sections/redirects3xx.yml',
],
'hooks' => [
'route:before' => function () {
$isPanel = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->panel());
$isApi = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->api());
$isMedia = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->media());
if (!$isPanel && !$isApi && !$isMedia) {
\Bnomei\Redirects::singleton()->redirect();
'page.render:before' => function (string $contentType, array $data, Kirby\Cms\Page $page) {
if ($page->isErrorPage()) {
$isPanel = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->panel());
$isApi = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->api());
$isMedia = str_contains(kirby()->request()->url()->toString(), kirby()->urls()->media());
if (!$isPanel && !$isApi && !$isMedia) {
\Bnomei\Redirects::singleton()->redirect();
}
}
},
'page.update:after' => function (Kirby\Cms\Page $newPage, Kirby\Cms\Page $oldPage) {
Expand Down
8 changes: 4 additions & 4 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php return array(
'root' => array(
'name' => 'bnomei/kirby3-redirects',
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'pretty_version' => '1.12.0',
'version' => '1.12.0.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand All @@ -11,8 +11,8 @@
),
'versions' => array(
'bnomei/kirby3-redirects' => array(
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'pretty_version' => '1.12.0',
'version' => '1.12.0.0',
'reference' => NULL,
'type' => 'kirby-plugin',
'install_path' => __DIR__ . '/../../',
Expand Down

0 comments on commit a455de9

Please sign in to comment.