DbUserGroupBackend: implement Inspectable

refs #3233
This commit is contained in:
Alexander A. Klimov 2018-01-19 12:22:19 +01:00 committed by Johannes Meyer
parent 7227e10824
commit 7106de5aa2
1 changed files with 23 additions and 1 deletions

View File

@ -3,13 +3,16 @@
namespace Icinga\Authentication\UserGroup;
use Exception;
use Icinga\Data\Filter\Filter;
use Icinga\Data\Inspectable;
use Icinga\Data\Inspection;
use Icinga\Exception\NotFoundError;
use Icinga\Repository\DbRepository;
use Icinga\Repository\RepositoryQuery;
use Icinga\User;
class DbUserGroupBackend extends DbRepository implements UserGroupBackendInterface
class DbUserGroupBackend extends DbRepository implements Inspectable, UserGroupBackendInterface
{
/**
* The query columns being provided
@ -300,4 +303,23 @@ class DbUserGroupBackend extends DbRepository implements UserGroupBackendInterfa
return $groupId;
}
/**
* Inspect this object to gain extended information about its health
*
* @return Inspection The inspection result
*/
public function inspect()
{
$insp = new Inspection('Db User Group Backend');
$insp->write($this->ds->inspect());
try {
$insp->write(sprintf('%s group(s)', $this->select()->count()));
} catch (Exception $e) {
$insp->error(sprintf('Query failed: %s', $e->getMessage()));
}
return $insp;
}
}