streams/Code/Extend/Widget.php
Mike Macgirvin 0c1a256139 more cleanup
2022-08-21 17:36:09 +10:00

52 lines
1 KiB
PHP

<?php
namespace Code\Extend;
class Widget
{
public static function register($file, $widget): void
{
$rt = self::get();
$rt[] = [$file, $widget];
self::set($rt);
}
public static function unregister($file, $widget): void
{
$rt = self::get();
if ($rt) {
$n = [];
foreach ($rt as $r) {
if ($r[0] !== $file && $r[1] !== $widget) {
$n[] = $r;
}
}
self::set($n);
}
}
public static function unregister_by_file($file): void
{
$rt = self::get();
if ($rt) {
$n = [];
foreach ($rt as $r) {
if ($r[0] !== $file) {
$n[] = $r;
}
}
self::set($n);
}
}
public static function get()
{
return get_config('system', 'widgets', []);
}
public static function set($r)
{
return set_config('system', 'widgets', $r);
}
}