SampleRestservice
extends CSRestservicePlugin
in package
Provides a sample REST service for reference.
Tags
Table of Contents
- METHOD_NOT_IMPLEMENTED = 'METHOD_NOT_IMPLEMENTED'
- __call() : mixed|string
- All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.
- _construct() : void
- The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.
- addAlternativePluginFolder() : void
- A path to a specific folder in which should be search for plugins.
- addExternalParam() : CSRestserviceParam
- Call this method to add Internal property attribute to the REST service.
- addHTTPHeader() : mixed
- Sets the HTTP response header value.
- addInternalParam() : CSRestserviceParam
- Call this method to add Internal property attribute to the REST service.
- addParam() : CSRestserviceParam
- Call this method to add property attribute to the REST service.
- addParams() : mixed
- This method is used to add your own properties to the rest service.
- addStandardParams() : void
- This method adds predefined parameters to the rest service. eg. content type selection list.
- addXmlAttribute() : mixed
- callDirectoryAsFunction() : mixed
- callDirectoryAsFunctionOnPlugin() : mixed
- error() : mixed
- Sends an immediate error message to the client together with status code 400
- execute() : mixed
- This method is executed when a REST service is accessed.
- executeAbout() : file
- Creates the webservices api page
- executeDefault() : mixed
- This method is executed when a REST service is accessed without any directory
- executeDocumentationForGET() : array<string|int, mixed>|file|string|void
- Used to generate documentations for the rest service.
- executeFooForGet() : the
- This is the Foo Method
- executeInfoForGET() : array<string|int, mixed>
- Returns information about the provided service.
- executeTokenForGet() : array<string|int, mixed>
- Creates a rest authentication token for the current user, the provided validity and endpoint.
- executeTokenForPost() : array<string|int, mixed>
- Creates a rest authentication token for the current user, the provided validity and endpoint.
- getAbout() : array<string|int, mixed>
- This method gives information about the current REST service
- getAlternativePluginFolder() : array<string|int, mixed>
- getApi() : CSRestserviceApi
- This method delivers the API methods of a CSRestservice
- getApiVersion() : int
- Get the version number of called API Version The version number can be provided in the url like /admin/rest/v5/foo/bar for the version 5 If not provided the default is 0.
- getCacheMinutes() : string
- Gets the CacheMinutes attribute.
- getCategory() : string
- Gets the Category attribute.
- getContentDisposition() : mixed
- getContentType() : string
- Gets the content-type HTTP header for the response. Default is text/html
- getCurrentDuration() : int
- Gets the current duration
- getDefaultCategory() : string
- Gets the default category name to be set when the the REST service is created automatically via the REST service URL.
- getDefaultFormat() : string
- Gets the default content type to be set when the the REST service is created automatically via the REST service URL.
- getDescription() : string
- Gets the description of the rest service
- getDirectories() : array<string|int, mixed>
- Gets the directory slash parameters.
- getDirectory() : string
- Gets the name of the directory slash parameters.
- getDocumentation() : string
- Gets the Documentation for the current REST service plugin.
- getExtensions() : array<string|int, CSRestserviceExtension>
- Retrieves all available Plugins of the type CSRestserviceExtension that match the Name of the Restservice Plugin while adding a Prefix and ending with Restextension.
- getExternalBoolParam() : bool
- Gets the external BOOL parameter value as sent by POST or GET.
- getExternalIntParam() : int
- Gets the external INT parameter value as sent by POST or GET.
- getExternalJsonParam() : array<string|int, mixed>|stdClass
- Gets the external parameter value as sent by POST or GET and json_decodes it.
- getExternalParam() : mixed
- Gets the external parameter value as sent by POST or GET.
- getFileNamePattern() : string
- Gets the file name pattern.
- getFormat() : string
- Gets the format defined for this plugin
- getHashKey() : string
- Gets the Hash key.
- getHTTPAccept() : string
- Gets the HTTP Accept header value.
- getHTTPAcceptLanguage() : string
- Gets the HTTP Accept Language header value.
- getHttpBody() : mixed
- getHttpClientAppName() : string
- Gets the HTTP Client App Name that is send from CS mobile apps
- getHttpClientAppVersion() : string
- Gets the HTTP Client App Version that is send from CS mobile apps
- getHttpClientHeight() : string
- Gets the HTTP Client Height that is send from CS mobile apps
- getHttpClientLocation() : string
- Gets the HTTP Client Location that is send from CS mobile apps
- getHttpClientOrientation() : string
- Gets the HTTP Client Orientation that is send from CS mobile apps
- getHttpClientSystemVersion() : string
- Gets the HTTP Client System Version that is send from CS mobile apps
- getHttpClientWidth() : string
- Gets the HTTP Client Width that is send from CS mobile apps
- getHTTPEncoding() : string
- Gets the HTTP Accept Encoding header value.
- getHTTPHeader() : string
- Gets the HTTP header for the provided key.
- getHTTPMethod() : string
- Gets the HTTP method.
- getHTTPStatusCode() : int
- Gets the HTTP Status code.
- getHTTPUserAgent() : string
- Gets the HTTP User Agent header value.
- getInternalParam() : mixed
- Gets the internal parameter value.
- getIPs() : string
- Gets the IPs attribute.
- getLabel() : string
- Gets the Label attribute.
- getLevel() : int
- The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.
- getMetaData() : CSMetaData
- Returns the CSMetaData of the current plugin.
- getModule() : CSModule
- Returns the module, if the plugin is defined within a module.
- getParam() : REST
- Gets the REST parameter value.
- getParamObject() : CSRestserviceParam
- Gets the REST parameter value as a CSRestserviceParam object.
- getParams() : REST
- Gets the REST parameter array.
- getPlugin() : CSPlugin|null
- Returns a CSPlugin for the given plugin type and plugin class name.
- getPluginChooser() : array<string|int, mixed>
- Returns an array all defined CSPlugins for the current plugin type
- getPluginData() : mixed
- getPluginDefinitionFile() : string
- Returns the path to the file, the plugin is defined.
- getPluginName() : string
- Gets the name of the plugin name
- getPluginPath() : string
- Gets the plugin path.
- getPlugins() : array<string|int, CSPlugin>
- Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.
- getPluginsInModule() : array<string|int, mixed>
- Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.
- getRemoteAddress() : string
- Gets the Remote Address.
- getRequestURI() : string
- Gets the request URI.
- getRestservice() : CSRestservice
- Gets the CSRestservice object.
- getRunAsUserID() : string
- Gets the RunAsUserID attribute.
- getServiceKey() : string
- Gets the ServiceKey attribute.
- getServiceType() : int
- Marks the usage of rest service for only internal purposes
- getUrl() : string
- Gets the REST service URL
- getUserAccess() : string
- Gets the User Access Type attribute.
- getUserIDs() : string
- Gets the UserIDs attribute.
- init() : mixed
- Sets the CSRestservice object to the plugin.
- initParams() : void
- Loads all standard parameters for the current plugin It internally calls all required methods like addStandardParams and addParams
- isAvailable() : bool
- This method is called to check, whether the plugin is available.
- isAvailableForCurrentServiceType() : bool
- Returns if the current restservice plugin is available based on the service type information.
- isAvailableForCurrentUser() : bool
- Allows plugins to take control of the authentication of the REST call rather that Rest Framework.
- isCachable() : bool
- Check if the REST service is cachable.
- isDisabled() : bool
- Checks if the REST service is disabled.
- isHTTPSRequired() : bool
- Checks if HTTPS is required for the REST service.
- prepareEditor() : void
- Prepares the rest editor window
- resetLoadedPlugins() : mixed
- reset the internal plugins cache for loaded plugins
- setContentDisposition() : mixed
- setContentType() : mixed
- Set the content-type of the response header.
- setDefaultContentType() : mixed
- Set the default content-type of the response header.
- setFormat() : mixed
- Set the output format of the response header based on that the returned data is converted to.
- setHTTPCacheControl() : mixed
- Sets the HTTP response header value for Cache control.
- setHTTPContentEncoding() : mixed
- Sets the HTTP response header value for Content Encoding.
- setHTTPContentLength() : mixed
- Sets the HTTP response header value for Content Length.
- setHTTPExpires() : mixed
- Sets the HTTP response header value for Expires.
- setHttpStatusBadGateway() : mixed
- setHttpStatusBadRequest() : mixed
- setHTTPStatusCode() : mixed
- Sets the HTTP status code.
- setHttpStatusCreated() : mixed
- setHttpStatusForbidden() : mixed
- setHttpStatusHttpsRequired() : mixed
- setHttpStatusLocked() : mixed
- setHttpStatusMethodNotAllowed() : mixed
- setHttpStatusNoContent() : mixed
- setHttpStatusOK() : mixed
- setHttpStatusUnauthorized() : mixed
- setXmlTagname() : mixed
- shouldSkipAccessCheckForMethodWithName() : bool
- This method defines whether the current available user is allowed to access the given GET method name without any further authentication check.
- shouldSkipRestLicenseCheck() : bool
- This method defines whether the rest framework checks the rest license before accessing a restservice using this plugin. This method can only be overwritten in admin plugins, project side plugins changing the return value will cause an exception to be thrown.
Constants
METHOD_NOT_IMPLEMENTED
public
mixed
METHOD_NOT_IMPLEMENTED
= 'METHOD_NOT_IMPLEMENTED'
Tags
Methods
__call()
All method calls which are not defined within the plugin are forwarded to the module Therefore it is possible to get, e.g. the label by calling the getSuiteName() method.
public
__call(mixed $methodName, mixed $methodArguments) : mixed|string
Parameters
- $methodName : mixed
- $methodArguments : mixed
Tags
Return values
mixed|string —_construct()
The construct method may be used to initialize custom plugin properties it is called immediately after instantiating the plugin all arguments passed to the getPlugins method are also available in this method.
public
_construct() : void
Tags
Return values
void —addAlternativePluginFolder()
A path to a specific folder in which should be search for plugins.
public
static addAlternativePluginFolder(mixed $sPluginFolder) : void
Parameters
- $sPluginFolder : mixed
Tags
Return values
void —addExternalParam()
Call this method to add Internal property attribute to the REST service.
public
addExternalParam(string $name[, string $label = NULL ][, string $type = 'caption' ][, string $default = '' ][, bool $isRequired = FALSE ][, array<string|int, mixed> $additionalOptions = array() ]) : CSRestserviceParam
These parameters are default configurable by the admin and may be overwritten by the external caller. To retrieve the parameter you can call $this->getParam($name)
Parameters
- $name : string
-
The name of the property.
- $label : string = NULL
-
The label to be shown on the CS GUI form.
- $type : string = 'caption'
- $default : string = ''
- $isRequired : bool = FALSE
- $additionalOptions : array<string|int, mixed> = array()
Tags
Return values
CSRestserviceParam —Object for the parameter
addHTTPHeader()
Sets the HTTP response header value.
public
addHTTPHeader(string $name, string $value) : mixed
Parameters
- $name : string
-
the header key to be set
- $value : string
-
the header value to be set
Tags
Return values
mixed —addInternalParam()
Call this method to add Internal property attribute to the REST service.
public
addInternalParam(string $name[, string $label = NULL ][, string $type = 'caption' ][, string $default = '' ][, bool $isRequired = FALSE ][, array<string|int, mixed> $additionalOptions = array() ]) : CSRestserviceParam
These parameters are only configurable by the admin.
Parameters
- $name : string
-
The name of the property,
- $label : string = NULL
-
The label to be shown on the CS GUI form.
- $type : string = 'caption'
- $default : string = ''
- $isRequired : bool = FALSE
- $additionalOptions : array<string|int, mixed> = array()
Tags
Return values
CSRestserviceParam —Object for the parameter.
addParam()
Call this method to add property attribute to the REST service.
public
addParam(mixed $name[, mixed $label = NULL ][, mixed $type = 'caption' ][, mixed $default = '' ][, mixed $isRequired = FALSE ][, mixed $additionalOptions = array() ][, mixed $allowExternalOverwrite = TRUE ]) : CSRestserviceParam
Parameters
- $name : mixed
-
Name of the property
- $label : mixed = NULL
-
Label to be shown on the CS GUI form.
- $type : mixed = 'caption'
- $default : mixed = ''
- $isRequired : mixed = FALSE
- $additionalOptions : mixed = array()
- $allowExternalOverwrite : mixed = TRUE
Tags
Return values
CSRestserviceParam —object for the parameter
addParams()
This method is used to add your own properties to the rest service.
public
addParams() : mixed
It should essentially make calls to addParam() function.
This method is optional to be overwritten, as it is required only if you want to provide admin level parameters
Tags
Return values
mixed —addStandardParams()
This method adds predefined parameters to the rest service. eg. content type selection list.
public
final addStandardParams() : void
Tags
Return values
void —addXmlAttribute()
public
addXmlAttribute(mixed &$array, mixed $key, mixed $val) : mixed
Parameters
- $array : mixed
- $key : mixed
- $val : mixed
Tags
Return values
mixed —callDirectoryAsFunction()
public
final callDirectoryAsFunction(mixed $directory) : mixed
Parameters
- $directory : mixed
Tags
Return values
mixed —callDirectoryAsFunctionOnPlugin()
public
final callDirectoryAsFunctionOnPlugin(mixed $directory, mixed $plugin) : mixed
Parameters
- $directory : mixed
- $plugin : mixed
Tags
Return values
mixed —error()
Sends an immediate error message to the client together with status code 400
public
error(string $message[, string $description = '' ][, int $iErrorCode = 400 ]) : mixed
Parameters
- $message : string
-
The error message to be sent
- $description : string = ''
-
The description to be send
- $iErrorCode : int = 400
-
The error code that is used in the exception. Default value is the http error code 400.
Tags
Return values
mixed —execute()
This method is executed when a REST service is accessed.
public
execute() : mixed
You will have to override this method in your plugin, which will be called when the REST service using your plugin is accessed.When you don't overwrite this method the call will be forwarded depending on the first directory parameter. For example when you call your Rest service foo with admin/rest/foo/sample then the method exeucteSample() will be called up. If no directory is defined then the method executeDefault() will be called up, which by default returns the API documentation.
Tags
Return values
mixed —Should Ideally be an array which will then be converted based on the content type set
executeAbout()
Creates the webservices api page
public
executeAbout() : file
Tags
Return values
file —html api page
executeDefault()
This method is executed when a REST service is accessed without any directory
public
executeDefault([string $directory = '' ]) : mixed
It returns by default the API documentation.
Parameters
- $directory : string = ''
-
must be empty
Tags
Return values
mixed —depending on the implementation
executeDocumentationForGET()
Used to generate documentations for the rest service.
public
executeDocumentationForGET() : array<string|int, mixed>|file|string|void
Will return OpenAPI format when json is selected and getAbout return if html is selected.
Tags
Return values
array<string|int, mixed>|file|string|void —executeFooForGet()
This is the Foo Method
public
executeFooForGet(string $test) : the
Parameters
- $test : string
-
some sample string
Tags
Return values
the —ret value
executeInfoForGET()
Returns information about the provided service.
public
executeInfoForGET() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —key/value pairs of information.
executeTokenForGet()
Creates a rest authentication token for the current user, the provided validity and endpoint.
public
executeTokenForGet() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —A token definition
executeTokenForPost()
Creates a rest authentication token for the current user, the provided validity and endpoint.
public
executeTokenForPost() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —A token definition
getAbout()
This method gives information about the current REST service
public
getAbout() : array<string|int, mixed>
Returns a complete description like Label, ID, ServiceKey, Description, Internal Parameters, External Parameters and the developers documentation.
Tags
Return values
array<string|int, mixed> —information about the current REST service
getAlternativePluginFolder()
public
static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getApi()
This method delivers the API methods of a CSRestservice
public
getApi() : CSRestserviceApi
Tags
Return values
CSRestserviceApi —the api
getApiVersion()
Get the version number of called API Version The version number can be provided in the url like /admin/rest/v5/foo/bar for the version 5 If not provided the default is 0.
public
final getApiVersion() : int
Tags
Return values
int —the version number
getCacheMinutes()
Gets the CacheMinutes attribute.
public
getCacheMinutes() : string
Tags
Return values
string —CacheMinutes attribute
getCategory()
Gets the Category attribute.
public
getCategory() : string
Tags
Return values
string —Category attribute
getContentDisposition()
public
getContentDisposition() : mixed
Tags
Return values
mixed —getContentType()
Gets the content-type HTTP header for the response. Default is text/html
public
getContentType() : string
Tags
Return values
string —content-type HTTP header for the response
getCurrentDuration()
Gets the current duration
public
getCurrentDuration() : int
Tags
Return values
int —the current duration
getDefaultCategory()
Gets the default category name to be set when the the REST service is created automatically via the REST service URL.
public
getDefaultCategory() : string
Tags
Return values
string —the default category name
getDefaultFormat()
Gets the default content type to be set when the the REST service is created automatically via the REST service URL.
public
getDefaultFormat() : string
Tags
Return values
string —the default content type
getDescription()
Gets the description of the rest service
public
getDescription() : string
Tags
Return values
string —getDirectories()
Gets the directory slash parameters.
public
getDirectories(int $level, int $depth[, mixed $lowercase = TRUE ]) : array<string|int, mixed>
Parameters
- $level : int
-
the position of the directory parameter
- $depth : int
-
how many sub directories should be included, if 0 the complete remaining path is returned
- $lowercase : mixed = TRUE
Tags
Return values
array<string|int, mixed> —the parameter names as array
getDirectory()
Gets the name of the directory slash parameters.
public
getDirectory(int $level[, int $depth = 1 ][, mixed $lowercase = TRUE ]) : string
Parameters
- $level : int
-
the position of the directory parameter
- $depth : int = 1
-
how many sub directories should be included, if 0 the complete remaining path is returned
- $lowercase : mixed = TRUE
Tags
Return values
string —the parameter name at the provided level
getDocumentation()
Gets the Documentation for the current REST service plugin.
public
getDocumentation() : string
This method is optional to be overriden, as it is required only if you wish to provide your own documentation.
Tags
Return values
string —the REST service plugin documentation
getExtensions()
Retrieves all available Plugins of the type CSRestserviceExtension that match the Name of the Restservice Plugin while adding a Prefix and ending with Restextension.
public
getExtensions() : array<string|int, CSRestserviceExtension>
Tags
Return values
array<string|int, CSRestserviceExtension> —the extension plugins found
getExternalBoolParam()
Gets the external BOOL parameter value as sent by POST or GET.
public
getExternalBoolParam(string $name) : bool
Parameters
- $name : string
-
external parameter name
Tags
Return values
bool —The formatted data from the request.
getExternalIntParam()
Gets the external INT parameter value as sent by POST or GET.
public
getExternalIntParam(string $name) : int
Parameters
- $name : string
-
external parameter name
Tags
Return values
int —The formatted data from the request.
getExternalJsonParam()
Gets the external parameter value as sent by POST or GET and json_decodes it.
public
getExternalJsonParam(string $name[, bool $asArray = TRUE ]) : array<string|int, mixed>|stdClass
Parameters
- $name : string
-
external parameter name
- $asArray : bool = TRUE
-
If true the object will be converted to an array, otherwise it might be an object
Tags
Return values
array<string|int, mixed>|stdClass —Returns an array or stdClass
getExternalParam()
Gets the external parameter value as sent by POST or GET.
public
getExternalParam(string $name) : mixed
Parameters
- $name : string
-
external parameter name
Tags
Return values
mixed —The formatted data from the request.
getFileNamePattern()
Gets the file name pattern.
public
final getFileNamePattern() : string
Tags
Return values
string —file name pattern
getFormat()
Gets the format defined for this plugin
public
getFormat() : string
Tags
Return values
string —the format set for this plugin
getHashKey()
Gets the Hash key.
public
getHashKey() : string
Tags
Return values
string —hash key
getHTTPAccept()
Gets the HTTP Accept header value.
public
getHTTPAccept() : string
Tags
Return values
string —the value of the HTTP header HTTP_ACCEPT
getHTTPAcceptLanguage()
Gets the HTTP Accept Language header value.
public
getHTTPAcceptLanguage() : string
Tags
Return values
string —the value of the HTTP header HTTP_ACCEPT_LANGUAGE
getHttpBody()
public
getHttpBody() : mixed
Tags
Return values
mixed —getHttpClientAppName()
Gets the HTTP Client App Name that is send from CS mobile apps
public
getHttpClientAppName() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_APP_NAME
getHttpClientAppVersion()
Gets the HTTP Client App Version that is send from CS mobile apps
public
getHttpClientAppVersion() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_APP_VERSION
getHttpClientHeight()
Gets the HTTP Client Height that is send from CS mobile apps
public
getHttpClientHeight() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_HEIGHT
getHttpClientLocation()
Gets the HTTP Client Location that is send from CS mobile apps
public
getHttpClientLocation() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_LOCATION
getHttpClientOrientation()
Gets the HTTP Client Orientation that is send from CS mobile apps
public
getHttpClientOrientation() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_ORIENTATION, could be landscape or portrait
getHttpClientSystemVersion()
Gets the HTTP Client System Version that is send from CS mobile apps
public
getHttpClientSystemVersion() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_SYSTEM_VERSION
getHttpClientWidth()
Gets the HTTP Client Width that is send from CS mobile apps
public
getHttpClientWidth() : string
Tags
Return values
string —the value of the HTTP header HTTP_CS_CLIENT_WIDTH
getHTTPEncoding()
Gets the HTTP Accept Encoding header value.
public
getHTTPEncoding() : string
Tags
Return values
string —the value of the HTTP header HTTP_ACCEPT_ENCODING
getHTTPHeader()
Gets the HTTP header for the provided key.
public
getHTTPHeader(string $name) : string
Parameters
- $name : string
-
the key
Tags
Return values
string —the value of the HTTP header requested
getHTTPMethod()
Gets the HTTP method.
public
getHTTPMethod() : string
Tags
Return values
string —the value of the HTTP header REQUEST_METHOD
getHTTPStatusCode()
Gets the HTTP Status code.
public
getHTTPStatusCode() : int
Tags
Return values
int —the value of the HTTP status code
getHTTPUserAgent()
Gets the HTTP User Agent header value.
public
getHTTPUserAgent() : string
Tags
Return values
string —the value of the HTTP header HTTP_USER_AGENT
getInternalParam()
Gets the internal parameter value.
public
getInternalParam(string $name) : mixed
Parameters
- $name : string
-
internal parameter name
Tags
Return values
mixed —parameter value
getIPs()
Gets the IPs attribute.
public
getIPs() : string
Tags
Return values
string —IPs attribute
getLabel()
Gets the Label attribute.
public
getLabel() : string
Tags
Return values
string —Label attribute
getLevel()
The getLevel method may be overwritten in the plugins and defines the order, the plugins are called, where the highest level is called first.
public
getLevel() : int
The method can also be set for all plugins within a module by overwriting the modules getLevel method.
Tags
Return values
int —the level of the plugin where it is called
getMetaData()
Returns the CSMetaData of the current plugin.
public
getMetaData() : CSMetaData
Tags
Return values
CSMetaData —getModule()
Returns the module, if the plugin is defined within a module.
public
getModule() : CSModule
This method can be used in the plugin api and the plugin wherever access to the defining module is required. If it is used in the Api, it should be noticed that this method may return null, if the plugin is directly defined in the projects or admin.local plugins directory.
Tags
Return values
CSModule —the module object, if the plugin defined in a module or null otherwise
getParam()
Gets the REST parameter value.
public
getParam(string $name) : REST
Parameters
- $name : string
-
parameter name
Tags
Return values
REST —parameter value.
getParamObject()
Gets the REST parameter value as a CSRestserviceParam object.
public
getParamObject(string $name) : CSRestserviceParam
Parameters
- $name : string
-
parameter name
Tags
Return values
CSRestserviceParam —REST parameter value as a CSRestserviceParam object.
getParams()
Gets the REST parameter array.
public
getParams() : REST
Tags
Return values
REST —parameter array
getPlugin()
Returns a CSPlugin for the given plugin type and plugin class name.
public
static getPlugin(string $pluginApiPath, string $className[, mixed $arguments = NULL ]) : CSPlugin|null
As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.
Parameters
- $pluginApiPath : string
-
The relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).
- $className : string
-
The target plugin class name, which should be loaded.
- $arguments : mixed = NULL
-
one or multiple arguments which should be passed to the isAvailable method.
Tags
Return values
CSPlugin|null —Returns the requested plugin for the given parameter.
getPluginChooser()
Returns an array all defined CSPlugins for the current plugin type
public
static getPluginChooser(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
- $pluginApiPath : string
-
the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).
- $arguments : mixed = NULL
-
one ore multiple arguments which should be passed to the isAvailable method.
Tags
Return values
array<string|int, mixed> —of CSPlugins in the form [CLASSNAME => LABEL] where the CLASSNAME may be used in the CSPlugin::getPlugin method
getPluginData()
public
getPluginData() : mixed
Tags
Return values
mixed —getPluginDefinitionFile()
Returns the path to the file, the plugin is defined.
public
getPluginDefinitionFile() : string
Tags
Return values
string —the path to the plugin
getPluginName()
Gets the name of the plugin name
public
getPluginName() : string
Tags
Return values
string —name of the plugin
getPluginPath()
Gets the plugin path.
public
final getPluginPath() : string
Tags
Return values
string —the plugin path
getPlugins()
Returns all defined CSPlugins for the current plugin type It should be used to get all matching plugins for a given plugin api.
public
static getPlugins(string $pluginApiPath[, mixed $arguments = NULL ]) : array<string|int, CSPlugin>
As standard behaviour the module subfolder is guessed from the forward URL parameter. If a plugin should point to something in a special module subfolder, this scope can be added by adding the module name in squared bracket at the end of the $pluginApiPath, e.g. 'core/api/plugins/CSRecordPlugin.php[pms]' to get all CSRecordPlugins defined for pms records.
Parameters
- $pluginApiPath : string
-
the relative path in filesystem for the requested plugin api (optional: ending with the module subfolder).
- $arguments : mixed = NULL
-
one ore multiple arguments which should be passed to the isAvailable method.
Tags
Return values
array<string|int, CSPlugin> —array of CSPlugin objects matching the defined plugin criteria
getPluginsInModule()
Returns all CSPlugins for the current plugin type which are defined within the given module It should be used to get all matching plugins for a given plugin api.
public
static getPluginsInModule(string $moduleName, string $pluginApiPath[, mixed $sFileNamePattern = '' ][, mixed $arguments = NULL ]) : array<string|int, mixed>
Parameters
- $moduleName : string
-
the module which should be searched for plugins
- $pluginApiPath : string
-
the relative path in filesystem for the requested plugin api.
- $sFileNamePattern : mixed = ''
- $arguments : mixed = NULL
-
one ore multiple arguments which should be passed to the isAvailable method.
Tags
Return values
array<string|int, mixed> —of CSPlugin objects matching the defined plugin criterias
getRemoteAddress()
Gets the Remote Address.
public
getRemoteAddress() : string
Tags
Return values
string —Remote Address
getRequestURI()
Gets the request URI.
public
getRequestURI() : string
Tags
Return values
string —request URI
getRestservice()
Gets the CSRestservice object.
public
final getRestservice() : CSRestservice
Tags
Return values
CSRestservice —the CSRestservice object.
getRunAsUserID()
Gets the RunAsUserID attribute.
public
getRunAsUserID() : string
Tags
Return values
string —RunAsUserID attribute
getServiceKey()
Gets the ServiceKey attribute.
public
getServiceKey() : string
Tags
Return values
string —ServiceKey attribute
getServiceType()
Marks the usage of rest service for only internal purposes
public
getServiceType() : int
Tags
Return values
int —Service type identified by
getUrl()
Gets the REST service URL
public
final getUrl([string $function = '' ][, array<string|int, mixed> $directories = array() ][, array<string|int, mixed> $get = array() ][, string $format = '' ][, string $base = 'external' ][, string $anchor = '' ][, string $userName = '' ]) : string
Parameters
- $function : string = ''
-
the first parameter after the service key, which is normally the base function
- $directories : array<string|int, mixed> = array()
-
an array with further path parameters
- $get : array<string|int, mixed> = array()
-
an associative array with GET key=>val parameters, that should be appended after the ? character
- $format : string = ''
-
the format in which the webservice should deliver results, normally html, json or xml
- $base : string = 'external'
-
the base of the URL. Possible is external, internal, relative or absolute
- $anchor : string = ''
-
an optional anchor that should be appended after a hash (#)
- $userName : string = ''
-
User name of current user.
Tags
Return values
string —the REST service URL
getUserAccess()
Gets the User Access Type attribute.
public
getUserAccess() : string
Tags
Return values
string —UserAcces attribute, 0 for everybody excluding anonymous, 1 for everybody including anonymous, 2 only for the users specified by the method getUserIDs()
getUserIDs()
Gets the UserIDs attribute.
public
getUserIDs() : string
Tags
Return values
string —UserIDs attribute
init()
Sets the CSRestservice object to the plugin.
public
final init(CSRestservice $restservice) : mixed
Parameters
- $restservice : CSRestservice
-
CSRestservice object
Tags
Return values
mixed —initParams()
Loads all standard parameters for the current plugin It internally calls all required methods like addStandardParams and addParams
public
initParams() : void
Tags
Return values
void —isAvailable()
This method is called to check, whether the plugin is available.
public
isAvailable() : bool
If further arguments are added to the CSPlugin::getPlugins call, they are added as arguments to this method.
For simpler usage of the plugin concept: This method should be overwritten with the correct signature for a plugin call, if arguments are passed.
Tags
Return values
bool —whether the plugin is available for the given arguments
isAvailableForCurrentServiceType()
Returns if the current restservice plugin is available based on the service type information.
public
final isAvailableForCurrentServiceType() : bool
Tags
Return values
bool —True, if plugin is available, otherwise false
isAvailableForCurrentUser()
Allows plugins to take control of the authentication of the REST call rather that Rest Framework.
public
isAvailableForCurrentUser() : bool
This method can only be overwritten in admin plugins, project side plugins changing the return value will cause an exception to be thrown.
Tags
Return values
bool —false, if the REST request is valid for the current user.
isCachable()
Check if the REST service is cachable.
public
isCachable() : bool
Tags
Return values
bool —REST service cachable
isDisabled()
Checks if the REST service is disabled.
public
isDisabled() : bool
Tags
Return values
bool —REST service disabled
isHTTPSRequired()
Checks if HTTPS is required for the REST service.
public
isHTTPSRequired() : bool
Tags
Return values
bool —HTTPS required for REST service
prepareEditor()
Prepares the rest editor window
public
prepareEditor(mixed $editor) : void
You may overwrite this method to add rest specific configuration parameters. The simplest way to do so is to call the addParam method for each param you wish to add. As the rest is a property record you have not to take care of the storage of the params.
Parameters
- $editor : mixed
-
the CSGuiEditor that edits the rest settings
Tags
Return values
void —resetLoadedPlugins()
reset the internal plugins cache for loaded plugins
public
static resetLoadedPlugins() : mixed
Tags
Return values
mixed —setContentDisposition()
public
setContentDisposition(mixed $fileName) : mixed
Parameters
- $fileName : mixed
Tags
Return values
mixed —setContentType()
Set the content-type of the response header.
public
setContentType(string $type) : mixed
Parameters
- $type : string
-
content-type of the response header, e.g. text/html
Tags
Return values
mixed —setDefaultContentType()
Set the default content-type of the response header.
public
setDefaultContentType(string $type) : mixed
Parameters
- $type : string
-
default content-type of the response header
Tags
Return values
mixed —setFormat()
Set the output format of the response header based on that the returned data is converted to.
public
setFormat(mixed $format) : mixed
For example if you set here the format to json and return in an execute method an array, then the array will be converted to json and the content type will be automatically set to application/json
Parameters
- $format : mixed
Tags
Return values
mixed —setHTTPCacheControl()
Sets the HTTP response header value for Cache control.
public
setHTTPCacheControl(string $value) : mixed
Parameters
- $value : string
-
the header value to be set for Cache-Control
Tags
Return values
mixed —setHTTPContentEncoding()
Sets the HTTP response header value for Content Encoding.
public
setHTTPContentEncoding(string $value) : mixed
Parameters
- $value : string
-
the header value to be set for Content-Encoding
Tags
Return values
mixed —setHTTPContentLength()
Sets the HTTP response header value for Content Length.
public
setHTTPContentLength(string $value) : mixed
Parameters
- $value : string
-
the header value to be set for Content-Length
Tags
Return values
mixed —setHTTPExpires()
Sets the HTTP response header value for Expires.
public
setHTTPExpires(int $seconds) : mixed
Parameters
- $seconds : int
-
value in number of seconds to be set for the Expires header value
Tags
Return values
mixed —setHttpStatusBadGateway()
public
setHttpStatusBadGateway() : mixed
Tags
Return values
mixed —setHttpStatusBadRequest()
public
setHttpStatusBadRequest() : mixed
Tags
Return values
mixed —setHTTPStatusCode()
Sets the HTTP status code.
public
setHTTPStatusCode(int $code) : mixed
Parameters
- $code : int
-
The status code value to be set.
Tags
Return values
mixed —setHttpStatusCreated()
public
setHttpStatusCreated() : mixed
Tags
Return values
mixed —setHttpStatusForbidden()
public
setHttpStatusForbidden() : mixed
Tags
Return values
mixed —setHttpStatusHttpsRequired()
public
setHttpStatusHttpsRequired() : mixed
Tags
Return values
mixed —setHttpStatusLocked()
public
setHttpStatusLocked() : mixed
Tags
Return values
mixed —setHttpStatusMethodNotAllowed()
public
setHttpStatusMethodNotAllowed() : mixed
Tags
Return values
mixed —setHttpStatusNoContent()
public
setHttpStatusNoContent() : mixed
Tags
Return values
mixed —setHttpStatusOK()
public
setHttpStatusOK() : mixed
Tags
Return values
mixed —setHttpStatusUnauthorized()
public
setHttpStatusUnauthorized() : mixed
Tags
Return values
mixed —setXmlTagname()
public
setXmlTagname(mixed &$array, mixed $tagname) : mixed
Parameters
- $array : mixed
- $tagname : mixed
Tags
Return values
mixed —shouldSkipAccessCheckForMethodWithName()
This method defines whether the current available user is allowed to access the given GET method name without any further authentication check.
public
shouldSkipAccessCheckForMethodWithName(string $sMethodName) : bool
This allows Anonymous access to GET methods, which should be always available in a restservice.
Parameters
- $sMethodName : string
Tags
Return values
bool —shouldSkipRestLicenseCheck()
This method defines whether the rest framework checks the rest license before accessing a restservice using this plugin. This method can only be overwritten in admin plugins, project side plugins changing the return value will cause an exception to be thrown.
public
shouldSkipRestLicenseCheck() : bool
Tags
Return values
bool —false, if the license should be checked (default), otherwise true.
