1) You can use class \Magento\Authorization\Model\ResourceModel\Role\Grid\Collection
to get admin roles:
protected $roleCollectionFactory;
public function __construct(
\Magento\Authorization\Model\ResourceModel\Role\Grid\CollectionFactory $roleCollectionFactory,
) {
$this->roleCollectionFactory = $roleCollectionFactory;
}
public function getRoles()
{
$role = $this->roleCollectionFactory->create();
print_r($role->getData());
}
2) Use class Magento\Authorization\Model\ResourceModel\Role\Collection
to get admin role with all admin user:
protected $roleCollectionFactory;
public function __construct(
\Magento\Authorization\Model\ResourceModel\Role\CollectionFactory $roleCollectionFactory,
) {
$this->roleCollectionFactory = $roleCollectionFactory;
}
public function getRoles()
{
$role = $this->roleCollectionFactory->create();
print_r($role->getData());
}