code: protected function getResourceId($resource)
      {
          if ($resource instanceof PermissionsResourceInterface) {
              return $resource->getPermissionsResourceId();
          }
          
          if ($resource instanceof UserInterface) {
              return 'user:' . $resource->getId();
          }
          
          return 'user:' . $resource;
      }
docs: Gets/Generates the resource id.
  
  @param string|UserInterface|PermissionsResourceInterface $resource
  
  @return string