SDK
SDK PHP v3.x
1

You are currently looking at the documentation of a previous version of Kuzzle. We strongly recommend that you use the latest version. You can also use the version selector in the top menu.

searchRoles #

Search for security roles, optionally returning only the roles giving access to the provided controller names.


searchRoles(filters, [options], callback) #

ArgumentsTypeDescription
filtersJSON ObjectOptionally contains a "controllers" array listing the controller names used to filter searched roles
optionsJSON ObjectOptional parameters
callbackfunctionCallback handling the response

Filters #

FilterTypeDescriptionDefault
controllersarrayretrieve only roles allowing access to the provided names[]

Options #

OptionTypeDescriptionDefault
fromnumberStarting offset0
queuablebooleanMake this request queuable or nottrue
sizenumberNumber of hits to return per page10

Callback Response #

Return a JSON Object

Usage #

<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Role;
use \Kuzzle\Util\RolesSearchResult;
// optional: retrieve only roles allowing access to the
// provided controller names
$filters = [
  'controllers' => [
    'document',
    'security'
  ]
];
// optional: result pagination configuration
$options = [
  'size' => 10,
  'from' => 0
];
$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();
try {
  $result = $security->searchRoles($filters, $options);
  // $result instanceof RolesSearchResult
  foreach($result->getRoles() as $role) {
    // $role instanceof Role
  }
}
catch (ErrorException $e) {
}

Callback response:

{
  "total": 124,
  "roles": [
    // array of Role
  ]
}