Auto clear old menu entries on install

This commit is contained in:
slawkens 2024-01-27 14:15:42 +01:00
parent 6cd8b7697d
commit c8d4e7d186

View File

@ -712,17 +712,15 @@ class Plugins {
* @param string $templateName
* @param array $categories
*/
public static function installMenus($templateName, $categories)
public static function installMenus($templateName, $categories, $clearOld = true)
{
global $db;
if (!$db->hasTable(TABLE_PREFIX . 'menu')) {
return;
}
// check if menus already exist
$menuInstalled = Menu::where('template', $templateName)->select('id')->first();
if ($menuInstalled) {
return;
if ($clearOld) {
Menu::where('template', $templateName)->delete();
}
foreach ($categories as $category => $menus) {