mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-16 18:26:06 +01:00
Automatically redirect to new admin_route after changing it #1371
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
# v1.7.1
|
||||||
|
## mm/dd/2018
|
||||||
|
|
||||||
|
1. [](#bugfix)
|
||||||
|
* Automatically redirect to new `admin_route` after changing it [#1371](https://github.com/getgrav/grav-plugin-admin/issues/1371)
|
||||||
|
|
||||||
# v1.7.0
|
# v1.7.0
|
||||||
## 03/09/2018
|
## 03/09/2018
|
||||||
|
|
||||||
|
|||||||
11
admin.php
11
admin.php
@@ -606,6 +606,7 @@ class AdminPlugin extends Plugin
|
|||||||
'onAssetsInitialized' => ['onAssetsInitialized', 1000],
|
'onAssetsInitialized' => ['onAssetsInitialized', 1000],
|
||||||
'onAdminRegisterPermissions' => ['onAdminRegisterPermissions', 0],
|
'onAdminRegisterPermissions' => ['onAdminRegisterPermissions', 0],
|
||||||
'onOutputGenerated' => ['onOutputGenerated', 0],
|
'onOutputGenerated' => ['onOutputGenerated', 0],
|
||||||
|
'onAdminAfterSave' => ['onAdminAfterSave', 0],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Autoload classes
|
// Autoload classes
|
||||||
@@ -772,6 +773,16 @@ class AdminPlugin extends Plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function onAdminAfterSave(Event $event)
|
||||||
|
{
|
||||||
|
// Special case to redirect after changing the admin route to avoid 'breaking'
|
||||||
|
$obj = $event['object'];
|
||||||
|
if (isset($obj->route) && $this->admin_route !== $obj->route) {
|
||||||
|
$redirect = str_replace($this->admin_route, $obj->route, $this->uri->path() );
|
||||||
|
$this->grav->redirect($redirect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide the tools for the Tools page, currently only direct install
|
* Provide the tools for the Tools page, currently only direct install
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user