for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
/**
* /src/Security/RolesService.php
*
* @author TLe, Tarmo Leppänen <[email protected]>
*/
namespace App\Security;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use function array_unique;
use function array_values;
* Class RolesService
* @package App\Security
class RolesService
{
public function __construct(
private readonly RoleHierarchyInterface $roleHierarchy,
) {
}
* Helper method to get inherited roles for given roles.
* @param array<int, string> $roles
* @return array<int, string>
public function getInheritedRoles(array $roles): array
return array_values(array_unique($this->roleHierarchy->getReachableRoleNames($roles)));