Realm Manager¶
Realm Class¶
The class Realm is a
Realm Representation.
| Class | File |
|---|---|
KeycloakAdmin\Realm\Realm |
src/Realm/Realm.php |
List Realms¶
This method returns a collection of realms.
Usage¶
public function listRealms()
{
$collectionOfRealms = $this->admin->realms()->list();
foreach ($collectionOfRealms as $realm) {
var_dump($realm->getRealm());
}
}
Save Realm¶
This method returns will save a new Realm.
Usage¶
public function createRealm(string $name)
{
$myRealm = [
'realm' => $name
];
$realm = $this->admin->realms()->createFromArray($myRealm)->save();
}
Show Realm¶
This method returns a Realm, realmName must be passed as parameter. If Realm was not found, you will receive an Exception.
Usage¶
public function showRealm(string $realmName) : Realm
{
return $this->admin->realms()->show($realmName);
}
Update Realm¶
This method will update a Realm, an instance of Realm must be created
before call to update. This expects at least realm to can update.
In this Library, you can’t update the realm name.
Usage¶
public function update(string $realmName, array $params = []) : Realm
{
$data = [
'realm' => $realmName
] + $params;
return $this->admin->realms()->createFromArray($data)->update();
}
Delete Realm¶
This method will delete a Realm, realmName must be passed as parameter.
If an error occurs you will receive an Exception otherwise, this
is a void method
Usage¶
public function delete(string $realmName)
{
try {
$this->admin->realms()->delete($realmName);
} catch (\Exception $e) {
var_dump('cant delete this realm, ' . $e->getMessage());
}
}