SDK
SDK PHP v3.x
1

# Constructors

Instantiates a new Role object, which defines a set of right policies.


# Role(Security, id, content, [meta])

Arguments Type Description
Security Security An instantiated Security object
id string Unique role identifier
content JSON Object Role content
meta JSON Object Role metadata

Note: this constructor won't make any call to Kuzzle.


# Properties

Property name Type Description get/set
content JSON object Raw role content get
id string Unique profile identifier get
meta JSON object Role metadata get

# Return Value

Returns the Role object.

# Usage

Copied to clipboard!
<?php
use \Kuzzle\Kuzzle;
use \Kuzzle\Security\Role;
$roleId = 'myRole';
$roleDefinition = [
  'controllers' => [
    '*' => [
      'actions' => [
        '*' => true
      ]
    ]
  ]
];
$kuzzle = new Kuzzle('localhost');
$security = $kuzzle->security();
// Using the Security factory:
$role = $security->role($roleId, $roleDefinition);
// Or directly with the constructor:
$role = new Role($security, $roleId, $roleDefinition);