SurveyTemplate
in package
implements
CommandInterface
Uses
AuthPermissionTrait
Survey Template
Used by cloud / account to retrieve templates.
Table of Contents
Interfaces
Properties
- $responseFactory : ResponseFactory
- $session : CHttpSession
- $survey : Survey
- $surveyLanguageSetting : SurveyLanguageSetting
- $permissionModel : Permission|null
Methods
- __construct() : mixed
- Constructor
- run() : Response
- Run survey template command
- setPermissionModel() : void
- getPermissionModel() : Permission
- hasGlobalPermission() : Response
- hasSurveyPermission() : Response
- ensurePermissions() : Response|false
- Ensure Permissions
- getTemplateData() : Response|bool|string
- Get template data
Properties
$responseFactory
protected
ResponseFactory
$responseFactory
$session
protected
CHttpSession
$session
$survey
protected
Survey
$survey
$surveyLanguageSetting
protected
SurveyLanguageSetting
$surveyLanguageSetting
$permissionModel
private
Permission|null
$permissionModel
= null
Methods
__construct()
Constructor
public
__construct(ResponseFactory $responseFactory, CHttpSession $session, Survey $survey, SurveyLanguageSetting $surveyLanguageSetting) : mixed
Parameters
- $responseFactory : ResponseFactory
- $session : CHttpSession
- $survey : Survey
- $surveyLanguageSetting : SurveyLanguageSetting
run()
Run survey template command
public
run(Request $request) : Response
Supports GET and POST, with the sid at the end of the endpoint, lookin like rest/v1/survey-template/571271
If it's a GET request, then language is not specified, so it is inferred from the survey's default language and falling back to en if not found
If it's a POST, language can be specified like this: { "language": "en", }
Responds with an object, like this: { "template": "<some HTML>" "title": "Lunch" "subtitle": "What should we eat for lunch?" }
Parameters
- $request : Request
Return values
ResponsesetPermissionModel()
public
setPermissionModel(Permission $permissionModel) : void
Parameters
- $permissionModel : Permission
getPermissionModel()
protected
getPermissionModel() : Permission
Return values
PermissionhasGlobalPermission()
protected
hasGlobalPermission(string $sPermission, string $sCRUD[, int|null $iUserID = null ]) : Response
Parameters
- $sPermission : string
- $sCRUD : string
- $iUserID : int|null = null
Return values
Response —| boolean
hasSurveyPermission()
protected
hasSurveyPermission(int $iSurveyID, string $sPermission, string $sCRUD[, string|null $iUserID = null ]) : Response
Parameters
- $iSurveyID : int
- $sPermission : string
- $sCRUD : string
- $iUserID : string|null = null
Return values
Response —| boolean
ensurePermissions()
Ensure Permissions
private
ensurePermissions(int $surveyId) : Response|false
Parameters
- $surveyId : int
Return values
Response|falsegetTemplateData()
Get template data
private
getTemplateData(int $surveyId, string $language) : Response|bool|string
Parameters
- $surveyId : int
- $language : string