- 'Use' permission of apps now synced with Role - Added `PermissionData` DTO for standardized permission transformation. - Expanded `AppsPermissionService` with `getAllPermissions` method for retrieving connected app permissions. - Updated `AppRoleService` with methods for assigning and revoking app permissions to roles (`assignAppPermissionsRole`, `removeAppPermissionsRole`). - Introduced `AppPermission::type` method for extracting permission type from names. - Refined role and app interaction logic, including proper slug generation and app-role association.
32 lines
795 B
PHP
32 lines
795 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Helpers;
|
|
|
|
use App\Data\ConnectedApp\ConnectedAppData;
|
|
use App\Enums\ConnectedAppPermissonEnum;
|
|
|
|
class AppPermission
|
|
{
|
|
/**
|
|
* Generates the standard permission string.
|
|
*/
|
|
public static function name(ConnectedAppPermissonEnum $permission, string|ConnectedAppData $app): string
|
|
{
|
|
$slug = is_string($app) ? $app : $app->slug;
|
|
|
|
return "{$permission->value}-{$slug}";
|
|
}
|
|
|
|
/**
|
|
* @param string $permissionName This should be the name constructed by the {@see self::name()} method.
|
|
*/
|
|
public static function type(string $permissionName): ConnectedAppPermissonEnum
|
|
{
|
|
$permission = explode('-', $permissionName);
|
|
|
|
return ConnectedAppPermissonEnum::from($permission[0]);
|
|
}
|
|
}
|