-
-
Notifications
You must be signed in to change notification settings - Fork 10
Add Custom Settings
A useful feature of the Debug Toolbar (EEDT) is that you can integrate your Panel's, or custom extension's, settings into the EEDT settings mechanism. Doing this has a couple advantages:
Note: this tutorial assumes you're already familiar with EEDT extension development and have read Creating custom debug panels
- All settings are consolidated under one Settings Form (the EEDT one)
- Developers don't have to bother creating their own custom Settings Forms for their debug add-ons.
- Users have automatic access override config options for your add-ons once installed.
Doing this requires 2 hooks be used in order to, first, register your settings with the EEDT settings object and, second, to create the form elements for updating.
A good point of reference for this tutorial would be the Performance Alerts extension that comes bundled
You'll have to create 2 Extensions for your EEDT Add-on
This hook is to tell EEDT what your settings are and what values to use by default:
Be sure to always check for
ee()->extensions->last_calllike in the below to ensure you get all the other set settings.
namespace DebugToolbar\MemoryHistory\Extensions;
class EeDebugToolbarInitSettings extends AbstractHook
{
/**
* @var array|string[]
*/
protected array $default_settings = [
'memory_history_position' => "top right",
];
/**
* @param array $default_settings
* @return array
*/
public function process(array $default_settings): array
{
$default_settings = (ee()->extensions->last_call != '' ? ee()->extensions->last_call : $default_settings);
return array_merge($default_settings, $this->default_settings);
}
}