CSWorkflowActionPlugin
extends CSPlugin
in package
The CSWorkflowActionPlugins allows to add further fields to the Action Editor and functionality to Workflow Actions.
To be included, it must be placed in a workflow subfolder with a file name ending with WorkflowAction.php.
Tags
Table of Contents
- __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.
- addEditorFields() : mixed
- This methods is called in the action editor to add some additional fields to the editor Additional fields can be added using the addEditorField method Added fields can be removed using the removeEditorField method
- addError() : void
- Can be used to add error messages for error that occurred while the action had been executed this error are shown after the process in an alert window
- execute() : void|bool
- This method is called if the action is executed.
- getAlternativePluginFolder() : array<string|int, mixed>
- getErrors() : array<string|int, mixed>
- Returns the added error messages by all workflow plugins
- 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.
- 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.
- getPluginGroup() : string
- Returns the name of the group the plugin should be added to.
- getPluginName() : mixed
- 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.
- getRecordForExecution() : Record|Item
- Returns the Record a workflow action should be executed on (e.g. the action may be forwarded to a folder or to a specific child)
- isAvailable() : bool
- Check whether this plugin is available for one of the given records
- mayAutoRun() : bool
- Returns whether this plugin may be executed via automations
- mayExecute() : bool
- This method is called to check whether an action may be executed
- mayHandle() : bool
- Check whether this plugin is available for a given record.
- onAfterCompleteExecute() : mixed
- This method is called once after a all workflow actions have been executed
- onAfterExecute() : mixed
- This method is called each time after a workflow action was executed if the execution was successful (returned TRUE).
- onAfterRecursiveExecute() : mixed
- This method is called once after a recursive workflow action is executed if all executions were successful (returned TRUE).
- onBeforeExecute() : mixed
- This method is called each time before a workflow action is executed.
- onBeforeRecursiveExecute() : mixed
- This method is called once before a recursive workflow action is executed.
- onExecutionError() : mixed
- This method is called if an error occurred in the execute call.
- resetErrors() : void
- Resets the error list of the workflow plugin
- resetLoadedPlugins() : mixed
- reset the internal plugins cache for loaded plugins
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 —addEditorFields()
This methods is called in the action editor to add some additional fields to the editor Additional fields can be added using the addEditorField method Added fields can be removed using the removeEditorField method
public
addEditorFields(Action $oAction, Workflow $oWorkflow[, array<string|int, Record>|array<string|int, Item> $aoRecords = array() ]) : mixed
Parameters
- $oAction : Action
-
The current workflow Action record.
- $oWorkflow : Workflow
-
The current Workflow record.
- $aoRecords : array<string|int, Record>|array<string|int, Item> = array()
-
The Records which may be visible with this workflow.
Tags
Return values
mixed —addError()
Can be used to add error messages for error that occurred while the action had been executed this error are shown after the process in an alert window
public
addError(string $sMessage) : void
Parameters
- $sMessage : string
-
the error message to show
Tags
Return values
void —execute()
This method is called if the action is executed.
public
execute(Action $oAction, Record|Item $oRecord[, string $sNote = '' ]) : void|bool
Parameters
- $oAction : Action
-
The workflow Action record.
- $oRecord : Record|Item
-
The CONTENTSERV Record or Item the action is executed on.
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history).
Tags
Return values
void|bool —Returning FALSE results in an execution error and the method onExecutionError is called. Returning TRUE or VOID results in execution success.
getAlternativePluginFolder()
public
static getAlternativePluginFolder() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —getErrors()
Returns the added error messages by all workflow plugins
public
getErrors() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —a list of strings containing the error messages
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
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
getPluginGroup()
Returns the name of the group the plugin should be added to.
public
getPluginGroup() : string
Tags
Return values
string —the name of the plugin group (it must not be translated and will be translated automatically)
getPluginName()
public
getPluginName() : mixed
Tags
Return values
mixed —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
getRecordForExecution()
Returns the Record a workflow action should be executed on (e.g. the action may be forwarded to a folder or to a specific child)
public
getRecordForExecution(Action $oAction, Record|Item $oRecord) : Record|Item
Parameters
- $oAction : Action
-
the workflow Action record
- $oRecord : Record|Item
-
the Record or Item on which the action should be initial executed
Tags
Return values
Record|Item —the Record on which the action should be executed
isAvailable()
Check whether this plugin is available for one of the given records
public
isAvailable([array<string|int, Record>|array<string|int, Item> $records = null ]) : bool
Parameters
- $records : array<string|int, Record>|array<string|int, Item> = null
-
the records which should be checked
Tags
Return values
bool —whether this plugin may handle this record
mayAutoRun()
Returns whether this plugin may be executed via automations
public
mayAutoRun() : bool
Tags
Return values
bool —whether this plugin may be executed or not
mayExecute()
This method is called to check whether an action may be executed
public
mayExecute(Action $oAction, Record|Item $oRecord[, bool $bIsExecuting = false ]) : bool
Parameters
- $oAction : Action
-
the workflow Action record
- $oRecord : Record|Item
-
the CONTENTSERV Record or Item the action is executed on
- $bIsExecuting : bool = false
-
this flag returns whether a action is triggered for execution (true) or whether just the general state should be checked (false), e.g. to display the action chooser in a dialog.
Tags
Return values
bool —mayHandle()
Check whether this plugin is available for a given record.
public
mayHandle(Record|Item $oRecord) : bool
Parameters
- $oRecord : Record|Item
-
the record or Item which should be checked.
Tags
Return values
bool —whether this plugin may handle this record
onAfterCompleteExecute()
This method is called once after a all workflow actions have been executed
public
onAfterCompleteExecute(Action $oAction, array<string|int, Record>|array<string|int, Item> $aoRecords[, string $sNote = '' ]) : mixed
Parameters
- $oAction : Action
-
The workflow Action record
- $aoRecords : array<string|int, Record>|array<string|int, Item>
-
All Records/Items that have been changed
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —onAfterExecute()
This method is called each time after a workflow action was executed if the execution was successful (returned TRUE).
public
onAfterExecute(Action $oAction, Record|Item $oRecord[, string $sNote = '' ]) : mixed
Parameters
- $oAction : Action
-
the workflow Action record
- $oRecord : Record|Item
-
The record object the action is called on
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —onAfterRecursiveExecute()
This method is called once after a recursive workflow action is executed if all executions were successful (returned TRUE).
public
onAfterRecursiveExecute(Action $oAction, Record|Item $oRecord[, string $sNote = '' ]) : mixed
Parameters
- $oAction : Action
-
the workflow Action record
- $oRecord : Record|Item
-
The root record object the action is called on
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —onBeforeExecute()
This method is called each time before a workflow action is executed.
public
onBeforeExecute(Action $oAction, Record|Item $oRecord[, string $note = '' ]) : mixed
Parameters
- $oAction : Action
-
The workflow Action record
- $oRecord : Record|Item
-
The Record or Item object the action is called on
- $note : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —onBeforeRecursiveExecute()
This method is called once before a recursive workflow action is executed.
public
onBeforeRecursiveExecute(Action $oAction, Record|Item $oRecord[, string $sNote = '' ]) : mixed
Parameters
- $oAction : Action
-
The workflow Action record
- $oRecord : Record|Item
-
The root Record or Item object the action is called on
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —onExecutionError()
This method is called if an error occurred in the execute call.
public
onExecutionError(Action $oAction, Record|Item $oRecord[, string $sNote = '' ]) : mixed
Parameters
- $oAction : Action
-
The workflow Action record
- $oRecord : Record|Item
-
The record or Item object on which the error occurred
- $sNote : string = ''
-
A note which can be processed in the workflow plugin (e.g. to store in the history)
Tags
Return values
mixed —resetErrors()
Resets the error list of the workflow plugin
public
resetErrors() : void
Tags
Return values
void —resetLoadedPlugins()
reset the internal plugins cache for loaded plugins
public
static resetLoadedPlugins() : mixed
