SD_Action
extends SD_ComplexData
in package
Data type used to represent an actionable link to the a parent {@see SC_Element} method.
SD_Action creates a link using SI_Link,that triggers a specific method call on its parent SC_Element instance when activated. This is commonly used in administrative interfaces, reports, or lists to provide actions such as "View", "Update", or "Delete" for individual Element records.
The constructor defines the method name to be called on the parent Element, the text
to be displayed for the action link, and an optional icon. The actual URL or action
is generated using the renderer's action()
method, which builds the appropriate URL
to invoke the specified method on the current Element instance.
It extends SD_ComplexData as it facilitates interaction derived from the context of the Element.
Tags
Table of Contents
- $action : mixed
- $autoIncrement : mixed
- $components : mixed
- $create : bool
- indicates if the SimplOndata must be used in the add(capture) from
- $dataPrepare : mixed
- $delete : bool
- RSL 2022 aded "e Emebded" indicates if the SimplOndata must bre printed when deliting the element
- $embeded : bool
- RSL 2022 aded "e Emebded" indicates if the SimplOndata must bre printed when its parrent element i contained within another element
- $fetch : bool
- indicates if the SimplOndata must have a value in order to allow the storage of it's dataParent SimplOnelement
- $filterCriteria : string
- search operands: > < >= <= == != ~= ^= $=
- $fixedValue : mixed
- $inputName : string
- The name of the input field for forms.
- $invalidValueMessage : mixed
- $label : ing
- Data name or label as it must be presented to human readers (in forms, html tables, etc)
- $layouts : mixed
- $list : bool
- indicates if the SimplOndata must be used when several items are listed on a html table or list
- $methodToCall : mixed
- $name : mixed
- $parent : SC_Element
- $printValInInput : mixed
- $renderer : SR_htmlJQuery
- $renderOverride : mixed
- $required : bool
- indicates if the SimplOndata must have a value in order to allow the storage of it's dataParent SimplOnelement
- $search : bool
- indicates if the SimplOndata must be used in the search from
- $tip : mixed
- $tipInline : mixed
- $update : bool
- indicates if the SimplOndata must be used in the update from
- $val : mixed
- Data value
- $validationRequired : mixed
- $view : bool
- indicates if the SimplOndata must be used when generating the default HTML template
- __call() : mixed
- Auto Makes the Setters and Getters
- __construct() : mixed
- Constructor for the SD_Action class.
- __toString() : string
- Tells PHP how to render this object as a string
- action() : string
- Handles the action associated with the SD_Action instance.
- clear() : mixed
- Clears the value of a property or attribute
- clearValue() : mixed
- Clears the value of the Data object.
- dataFlags() : string|void
- Sets create, update, search, list, required and fetch flags according to the letters in $flags
- doCreate() : array<string|int, mixed>|null
- Prepares data for a create operation in the data source.
- doDelete() : mixed
- Performs actions during a delete operation.
- doRead() : array<string|int, mixed>|null
- Prepares data for a read operation from the data source.
- doSearch() : array<string|int, mixed>|null
- Prepares data for a search operation on the data source.
- doUpdate() : array<string|int, mixed>|null
- Prepares data for an update operation in the data source.
- filterCriteria() : mixed
- fixValue() : mixed
- Sets and fixes the value of the Data object, preventing further changes.
- getClass() : string
- Returns the object's class
- hasAttribute() : bool
- Checks if a an object has a specific method
- hasProperty() : bool
- Checks if a an object has a specific property
- inputName() : string
- Gives the name of the field for the create or update forms (usualy an HTML form)
- inputVal() : mixed|string
- Returns the value to be used in input fields, based on the `printValInInput` flag.
- instanceId() : mixed
- Run time id of the object used to creat ids to link things in the interface like Labels and Inputs
- InterfaceId() : string
- Returns a unique Interface ID for the Data object instance.
- isValid() : bool
- Validates the given value.
- label() : string
- Returns or sets the label for the data object.
- ObjectId() : mixed
- Class and instance id
- postCreate() : mixed
- Performs actions after data is created in the data source.
- postDelete() : mixed
- Performs actions after data is deleted from the data source.
- postRead() : mixed
- Performs actions after data is read from the data source.
- postSearch() : mixed
- Performs actions after a search is executed on the data source.
- postUpdate() : mixed
- Performs actions after data is updated in the data source.
- preCreate() : mixed
- Performs actions before data is created in the data source.
- preDelete() : mixed
- Performs actions before data is deleted from the data source.
- preRead() : mixed
- Performs actions before data is read from the data source.
- preSearch() : mixed
- Performs actions before a search is executed on the data source.
- preUpdate() : mixed
- Performs actions before data is updated in the data source.
- renderer() : SR_htmlJQuery
- Gets or sets the renderer for this Data object.
- show() : SI_Item|string|false
- Displays the complex data based on the specified method.
- showCreate() : mixed
- Generates the input field for creating a new data entry.
- showDelete() : mixed
- Generates the output for displaying the data in a deletion context.
- showEmbeded() : mixed
- Displays the data in an embedded context.
- showEmbededStrip() : mixed
- Returns a stripped-down, embedded representation of the Data value.
- showList() : mixed
- Displays the data for a list view.
- showSearch() : mixed
- Generates the input field or display for searching based on this data.
- showUpdate() : mixed
- Generates the input field for updating an existing data entry.
- showView() : mixed
- Displays the data for a single item view.
- val() : mixed
- Gets or sets the value of the Data object.
- viewVal() : mixed
- Returns the value of the Data object for viewing.
Properties
$action
protected
mixed
$action
$autoIncrement
protected
mixed
$autoIncrement
= \true
$components
protected
mixed
$components
$create
indicates if the SimplOndata must be used in the add(capture) from
protected
bool
$create
= \true
$dataPrepare
protected
mixed
$dataPrepare
$delete
RSL 2022 aded "e Emebded" indicates if the SimplOndata must bre printed when deliting the element
protected
bool
$delete
= \true
$embeded
RSL 2022 aded "e Emebded" indicates if the SimplOndata must bre printed when its parrent element i contained within another element
protected
bool
$embeded
= \true
$fetch
indicates if the SimplOndata must have a value in order to allow the storage of it's dataParent SimplOnelement
protected
bool
$fetch
= \true
$filterCriteria
search operands: > < >= <= == != ~= ^= $=
protected
string
$filterCriteria
= \true
Complex operations are just simple operations jointed with ANDs and ORs, so it'd be possible to create "Operators" objects that defines those complex operations.
(name > val1) OR (name < val2)
a <= x <= b a > x || x < b
$fixedValue
protected
mixed
$fixedValue
= \true
$inputName
The name of the input field for forms.
protected
string
$inputName
= \true
Tags
$invalidValueMessage
protected
mixed
$invalidValueMessage
= \true
$label
Data name or label as it must be presented to human readers (in forms, html tables, etc)
protected
ing
$label
= \true
Tags
$layouts
protected
mixed
$layouts
$list
indicates if the SimplOndata must be used when several items are listed on a html table or list
protected
bool
$list
= \true
$methodToCall
protected
mixed
$methodToCall
$name
protected
mixed
$name
= \true
$parent
protected
SC_Element
$parent
= \true
$printValInInput
protected
mixed
$printValInInput
= \true
$renderer
protected
SR_htmlJQuery
$renderer
= \true
$renderOverride
protected
mixed
$renderOverride
= \true
$required
indicates if the SimplOndata must have a value in order to allow the storage of it's dataParent SimplOnelement
protected
bool
$required
= \true
$search
indicates if the SimplOndata must be used in the search from
protected
bool
$search
= \true
$tip
protected
mixed
$tip
= \true
$tipInline
protected
mixed
$tipInline
= \true
$update
indicates if the SimplOndata must be used in the update from
protected
bool
$update
= \true
$val
Data value
protected
mixed
$val
= \true
Tags
$validationRequired
protected
mixed
$validationRequired
= \true
$view
indicates if the SimplOndata must be used when generating the default HTML template
protected
bool
$view
= \true
Methods
__call()
Auto Makes the Setters and Getters
public
__call( $name, $arguments) : mixed
Parameters
Return values
mixed —__construct()
Constructor for the SD_Action class.
public
__construct([string|null $label = null ], string $methodToCall, string $text[, string|null $icon = null ][, int|null $flags = null ][, mixed|null $val = null ][, mixed|null $filterCriteria = null ]) : mixed
Initializes an SD_Action instance, setting up the method to be called on the parent Element and creating the visual link element using SI_Link.
Parameters
- $label : string|null = null
-
An optional label for the data element.
- $methodToCall : string
-
The name of the method to call on the parent SC_Element instance.
- $text : string
-
The text to display for the action link.
- $icon : string|null = null
-
An optional icon to display alongside the link text.
- $flags : int|null = null
-
Optional flags for the data element.
- $val : mixed|null = null
-
Optional initial value for the data element.
- $filterCriteria : mixed|null = null
-
Optional criteria for filtering the data element.
Return values
mixed —__toString()
Tells PHP how to render this object as a string
public
__toString() : string
Return values
string —action()
Handles the action associated with the SD_Action instance.
public
action([string|null $action = null ]) : string
If an action is provided, it sets the internal action property. If no action
is provided and no internal action is set, it generates the action URL using
the renderer's action()
method. Otherwise, it returns the internally set action.
Parameters
- $action : string|null = null
-
An optional action string to set internally.
Return values
string —The generated or internally set action URL.
clear()
Clears the value of a property or attribute
public
clear(string $name) : mixed
Parameters
- $name : string
Return values
mixed —clearValue()
Clears the value of the Data object.
public
clearValue() : mixed
Return values
mixed —dataFlags()
Sets create, update, search, list, required and fetch flags according to the letters in $flags
public
dataFlags([string|null $flags = null ]) : string|void
The flags are represented by a string where each character indicates a specific use case: 'v' (view), 'c' (create), 'u' (update), 's' (search), 'l' (list), 'e' (embeded), 'r' (required), 'f' (fetch). Uppercase letters set the flag to true, lowercase letters set it to false.
Parameters
- $flags : string|null = null
-
Optional. A string containing the flags to set. If null, the current flags string is returned.
Return values
string|void —Returns the current flags string if $flags is null, otherwise sets the flags and returns nothing.
doCreate()
Prepares data for a create operation in the data source.
public
doCreate() : array<string|int, mixed>|null
This method is called by the parent Element's processData('doCreate')
method.
It should return an array of data relevant for creation if the data is creatable.
Tags
Return values
array<string|int, mixed>|null —An array containing data for the create operation, or null if the data is not creatable.
doDelete()
Performs actions during a delete operation.
public
doDelete() : mixed
This method is called by the parent Element's processData('doDelete')
method.
Child classes can override this to perform specific actions during deletion.
Tags
Return values
mixed —doRead()
Prepares data for a read operation from the data source.
public
doRead() : array<string|int, mixed>|null
This method is called by the parent Element's processData('doRead')
method.
It should return an array of data relevant for reading if the data is fetchable.
Tags
Return values
array<string|int, mixed>|null —An array containing data for the read operation, or null if the data is not fetchable.
doSearch()
Prepares data for a search operation on the data source.
public
doSearch() : array<string|int, mixed>|null
This method is called by the parent Element's processData('doSearch')
method.
It should return an array of data relevant for searching if the data is searchable and fetchable.
Tags
Return values
array<string|int, mixed>|null —An array containing data for the search operation, or null if the data is not searchable or fetchable.
doUpdate()
Prepares data for an update operation in the data source.
public
doUpdate() : array<string|int, mixed>|null
This method is called by the parent Element's processData('doUpdate')
method.
It should return an array of data relevant for updating if the data is updatable.
Tags
Return values
array<string|int, mixed>|null —An array containing data for the update operation, or null if the data is not updatable.
filterCriteria()
public
filterCriteria([mixed $filterCriteria = null ]) : mixed
Parameters
- $filterCriteria : mixed = null
Return values
mixed —fixValue()
Sets and fixes the value of the Data object, preventing further changes.
public
fixValue(mixed $val) : mixed
It also sets a render override to 'showFixedValue', thats used on the form interfaces.
Parameters
- $val : mixed
-
The value to set and fix.
Return values
mixed —getClass()
Returns the object's class
public
getClass() : string
Return values
string —The short class name of the object instance.
hasAttribute()
Checks if a an object has a specific method
public
hasAttribute(mixed $attribute) : bool
Parameters
- $attribute : mixed
Return values
bool —hasProperty()
Checks if a an object has a specific property
public
hasProperty(string $propName) : bool
Parameters
- $propName : string
Return values
bool —inputName()
Gives the name of the field for the create or update forms (usualy an HTML form)
public
inputName([string|null $inputName = null ]) : string
Parameters
- $inputName : string|null = null
-
Optional. The name to set for the input field. If null, the current input name is returned or derived.
Return values
string —The name of the input field.
inputVal()
Returns the value to be used in input fields, based on the `printValInInput` flag.
public
inputVal() : mixed|string
Return values
mixed|string —The data value or an empty string.
instanceId()
Run time id of the object used to creat ids to link things in the interface like Labels and Inputs
public
instanceId() : mixed
Return values
mixed —InterfaceId()
Returns a unique Interface ID for the Data object instance.
public
InterfaceId() : string
This ID can be used for generating unique Interface element IDs in forms or other interfaces.
Return values
string —A unique Interface ID for the instance.
isValid()
Validates the given value.
public
isValid(mixed $val) : bool
This is a base implementation that always returns true. Child classes should override this method to provide specific validation logic for their data type.
Parameters
- $val : mixed
-
The value to validate.
Return values
bool —True if the value is valid, false otherwise.
label()
Returns or sets the label for the data object.
public
label([string|null $label = null ]) : string
If setting, it updates the internal label. If getting and no label is set, it generates one from the data name and applies localization.
Parameters
- $label : string|null = null
-
Optional. The label to set. If null, the current label is returned.
Tags
Return values
string —The localized label for the data object.
ObjectId()
Class and instance id
public
ObjectId() : mixed
Return values
mixed —postCreate()
Performs actions after data is created in the data source.
public
postCreate() : mixed
This method is a hook for executing custom logic after the data has been stored for a new element.
It is called by the parent Element's processData('postCreate')
method.
Tags
Return values
mixed —postDelete()
Performs actions after data is deleted from the data source.
public
postDelete() : mixed
This method is a hook for executing custom logic after the data has been removed for an element.
It is called by the parent Element's processData('postDelete')
method.
Tags
Return values
mixed —postRead()
Performs actions after data is read from the data source.
public
postRead() : mixed
This method is a hook for executing custom logic after the data has been fetched or read.
It is called by the parent Element's processData('postRead')
method.
Tags
Return values
mixed —postSearch()
Performs actions after a search is executed on the data source.
public
postSearch() : mixed
This method is a hook for executing custom logic after search criteria have been applied.
It is called by the parent Element's processData('postSearch')
method.
Tags
Return values
mixed —postUpdate()
Performs actions after data is updated in the data source.
public
postUpdate() : mixed
This method is a hook for executing custom logic after the data has been updated for an existing element.
It is called by the parent Element's processData('postUpdate')
method.
Tags
Return values
mixed —preCreate()
Performs actions before data is created in the data source.
public
preCreate() : mixed
This method is a hook for executing custom logic before the data is stored for a new element.
Return values
mixed —preDelete()
Performs actions before data is deleted from the data source.
public
preDelete() : mixed
This method is a hook for executing custom logic before the data is removed for an element.
Return values
mixed —preRead()
Performs actions before data is read from the data source.
public
preRead() : mixed
This method is a hook for executing custom logic before the data is fetched or read.
Return values
mixed —preSearch()
Performs actions before a search is executed on the data source.
public
preSearch() : mixed
This method is a hook for executing custom logic before search criteria are applied.
Return values
mixed —preUpdate()
Performs actions before data is updated in the data source.
public
preUpdate() : mixed
This method is a hook for executing custom logic before the data is updated for an existing element.
Return values
mixed —renderer()
Gets or sets the renderer for this Data object.
public
renderer([SR_htmlJQuery|null $renderer = null ]) : SR_htmlJQuery
If no renderer is set for this Data object, it attempts to get the renderer from its parent Element. If no parent or renderer is found, it defaults to the global renderer.
Parameters
- $renderer : SR_htmlJQuery|null = null
-
Optional. The renderer instance to set. If null, the current renderer is returned.
Return values
SR_htmlJQuery —The renderer instance.
show()
Displays the complex data based on the specified method.
public
show(string $method) : SI_Item|string|false
This method handles the display logic for the complex data. It first checks for render overrides or fixed values. If a data preparation function is set, it is called. It then attempts to use a layout defined for the given method. If no specific layout is found but a 'showView' layout exists, it falls back to 'showView'.
Parameters
- $method : string
-
The display method to use (e.g., 'showView', 'showList').
Return values
SI_Item|string|false —An SI_Item instance representing the layout for the specified method, an empty string if render override is 'showEmpty', or false if no suitable layout is found.
showCreate()
Generates the input field for creating a new data entry.
public
showCreate() : mixed
This method provides the interface item element required for capturing the data when creating a new element. Returns the appropriate input field for creation.
Return values
mixed —The input element for creation.
showDelete()
Generates the output for displaying the data in a deletion context.
public
showDelete() : mixed
This method is used to render the data when an element is being prepared for deletion. Child classes should override this method to provide a specific representation for deletion.
Return values
mixed —The rendered output for deletion.
showEmbeded()
Displays the data in an embedded context.
public
showEmbeded() : mixed
This method is used when the data is displayed as part of another element. Returns the formatted value appropriate for embedding.
Return values
mixed —The rendered output for embedding.
showEmbededStrip()
Returns a stripped-down, embedded representation of the Data value.
public
showEmbededStrip() : mixed
By default, this returns the raw value. Child classes can override this for specific formatting.
Return values
mixed —The stripped-down embedded value.
showList()
Displays the data for a list view.
public
showList() : mixed
This method is used to render the data when multiple elements are displayed in a list or table. Returns the formatted value appropriate for a list view.
Return values
mixed —The rendered output for listing.
showSearch()
Generates the input field or display for searching based on this data.
public
showSearch() : mixed
This method is used to create the form element or display representation for searching. Returns the appropriate input field or display for searching.
Return values
mixed —The input element or display for searching.
showUpdate()
Generates the input field for updating an existing data entry.
public
showUpdate() : mixed
This method provides the interface item element required for modifying the data of an existing element. Returns the appropriate input field for updating, potentially pre-filled with the current value.
Return values
mixed —The input element for updating.
showView()
Displays the data for a single item view.
public
showView() : mixed
This method is typically used to render the data in a detailed view of an element. Returns the formatted value appropriate for a detailed view.
Return values
mixed —The rendered output for viewing.
val()
Gets or sets the value of the Data object.
public
val([mixed $val = null ]) : mixed
If a value is provided, it attempts to set it after validation, unless the value is fixed. If no value is provided, it returns the current value.
Parameters
- $val : mixed = null
-
Optional. The value to set. Defaults to null.
Tags
Return values
mixed —The current value of the Data object if no value is provided for setting.
viewVal()
Returns the value of the Data object for viewing.
public
viewVal() : mixed
This method provides the raw value suitable for simple display.
Return values
mixed —The current value of the Data object.