mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-03 03:46:30 +01:00
Made all the onAdmin CRUD events to pass object (and backwards compatible page) to make them easier to use
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# v1.10.0-rc.16
|
# v1.10.0-rc.16
|
||||||
## mm/dd/2020
|
## mm/dd/2020
|
||||||
|
|
||||||
|
1. [](#improved)
|
||||||
|
* Made all the `onAdmin*` CRUD events to pass `object` (and backwards compatible `page`) to make them easier to use
|
||||||
1. [](#bugfix)
|
1. [](#bugfix)
|
||||||
* Fixed issue with File field being used in Theme/Plugins
|
* Fixed issue with File field being used in Theme/Plugins
|
||||||
|
|
||||||
|
|||||||
@@ -1360,14 +1360,16 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
if ($obj) {
|
if ($obj) {
|
||||||
// Event to manipulate data before saving the object
|
// Event to manipulate data before saving the object
|
||||||
$this->grav->fireEvent('onAdminSave', new Event(['object' => &$obj]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminSave', new Event(['object' => &$obj, 'page' => &$obj]));
|
||||||
|
|
||||||
$obj->save($reorder);
|
$obj->save($reorder);
|
||||||
|
|
||||||
Cache::clearCache('invalidate');
|
Cache::clearCache('invalidate');
|
||||||
|
|
||||||
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
|
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_SAVED'), 'info');
|
||||||
$this->grav->fireEvent('onAdminAfterSave', new Event(['object' => $obj]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterSave', new Event(['object' => $obj, 'page' => $obj]));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (method_exists($obj, 'unsetRouteSlug')) {
|
if (method_exists($obj, 'unsetRouteSlug')) {
|
||||||
@@ -1463,7 +1465,8 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
Cache::clearCache('invalidate');
|
Cache::clearCache('invalidate');
|
||||||
|
|
||||||
$this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $page]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterSave', new Event(['object' => $page, 'page' => $page]));
|
||||||
|
|
||||||
// Enqueue message and redirect to new location.
|
// Enqueue message and redirect to new location.
|
||||||
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_COPIED'), 'info');
|
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_COPIED'), 'info');
|
||||||
@@ -1527,7 +1530,8 @@ class AdminController extends AdminBaseController
|
|||||||
Folder::delete($page->path());
|
Folder::delete($page->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->grav->fireEvent('onAdminAfterDelete', new Event(['page' => $page]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterDelete', new Event(['object' => $page, 'page' => $page]));
|
||||||
|
|
||||||
Cache::clearCache('invalidate');
|
Cache::clearCache('invalidate');
|
||||||
|
|
||||||
@@ -1618,13 +1622,15 @@ class AdminController extends AdminBaseController
|
|||||||
$aPage->validate();
|
$aPage->validate();
|
||||||
$aPage->filter();
|
$aPage->filter();
|
||||||
|
|
||||||
$this->grav->fireEvent('onAdminSave', new Event(['page' => &$aPage]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminSave', new Event(['object' => $aPage, 'page' => &$aPage]));
|
||||||
|
|
||||||
$aPage->save();
|
$aPage->save();
|
||||||
|
|
||||||
Cache::clearCache('invalidate');
|
Cache::clearCache('invalidate');
|
||||||
|
|
||||||
$this->grav->fireEvent('onAdminAfterSave', new Event(['page' => $aPage]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterSave', new Event(['object' => $aPage, 'page' => $aPage]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
|
$this->admin->setMessage($this->admin::translate('PLUGIN_ADMIN.SUCCESSFULLY_SWITCHED_LANGUAGE'), 'info');
|
||||||
@@ -2145,7 +2151,8 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
$page = $this->admin->page(true);
|
$page = $this->admin->page(true);
|
||||||
if ($page) {
|
if ($page) {
|
||||||
$this->grav->fireEvent('onAdminAfterAddMedia', new Event(['page' => $page]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterAddMedia', new Event(['object' => $page, 'page' => $page]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
@@ -2315,7 +2322,8 @@ class AdminController extends AdminBaseController
|
|||||||
|
|
||||||
$page = $this->admin->page(true);
|
$page = $this->admin->page(true);
|
||||||
if ($page) {
|
if ($page) {
|
||||||
$this->grav->fireEvent('onAdminAfterDelMedia', new Event(['page' => $page]));
|
// DEPRECATED: page
|
||||||
|
$this->grav->fireEvent('onAdminAfterDelMedia', new Event(['object' => $page, 'page' => $page]));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->admin->json_response = [
|
$this->admin->json_response = [
|
||||||
|
|||||||
Reference in New Issue
Block a user