<?php

namespace App\Services;

class StudioWidgetRegistry
{

public static function allowed():array
{

$role=

$_SESSION['role_code']
??'guest';

$all=[

'super_admin'=>[
'*'
],

'org_admin'=>[
'metrics',
'operations',
'insights',
'governance'
],

'organizer'=>[
'metrics',
'operations'
],

'conference_chair'=>[
'metrics',
'insights'
],

'reviewer'=>[
'metrics'
],

'author'=>[
'metrics'
]

];

return
$all[
$role
]
??
[];

}

public static function can(
string $widget
):bool
{

$allow=
self::allowed();

return

in_array(
'*',
$allow
)

||

in_array(
$widget,
$allow
);

}

}
