Scalr\Api\Rest\ApiApplication::checkPermissions PHP Method

checkPermissions() public method

checkPermissions(object $obj, bool $modify = false, $errorMessage='') checkPermissions(int $roleId, string $permissionId = null, $errorMessage='')
public checkPermissions ( $args )
    public function checkPermissions(...$args)
    {
        if (count($args) == 3) {
            $message = array_pop($args);
        } else {
            $message = null;
        }
        $result = $this->hasPermissions(...$args);
        if (!$result) {
            throw new ApiInsufficientPermissionsException($message);
        }
    }

Usage Example

Example #1
0
 /**
  * Checks whether the authenticated user either is authorized to the specified object or has permission to ACL Role
  *
  * checkPermissions(object $obj, bool $modify = false, $errorMessage='')
  * checkPermissions(int $roleId, string $permissionId = null, $errorMessage='')
  *
  * @throws ApiInsufficientPermissionsException
  */
 public function checkPermissions(...$args)
 {
     $this->app->checkPermissions(...$args);
 }