Documentation

Script extends Node
in package

Class Script.

Table of Contents

EDIT_STATUS  = [0 => '', 1 => 'In Work', 2 => 'In Review', 3 => 'Approved', 4 => 'Done']
$attributes  : array<string|int, mixed>
$children  : array<string|int, mixed>
$db  : PgSQL
Database instance
$db_config  : TiqConfig
Config instance
$debug  : bool
Is debug mode or not
$description  : string
$display_name  : string
$error_message  : mixed
Base error message, this belongs in com_think's configuration class
$id  : int
$is_class_script  : bool
$nodes  : array<string|int, mixed>
$parent  : Node|null
$relationshipsDown  : array<string|int, mixed>
$relationshipsUp  : array<string|int, mixed>
$relative_name  : string
$script  : string
$script_type  : string
$scripts  : array<string|int, mixed>
$system_node_type_id  : int
$totalAttributes  : int|null
$totalScripts  : int|null
$allowed_props  : array<string|int, mixed>
$called_constructor  : bool
$class_script  : Script|null
$created_timestamp  : string|null
$cron_expression  : string|null
$description  : string|null
$display_name  : string|null
$display_path  : string|null
$document  : string|null
$edit_status  : string|null
$fqn  : string|null
$id  : int|null
$id_path  : string|null
$initial_inputs  : string|null
$is_root  : bool|null
$library  : Library|null
$max_acceptable_run_secs  : int|null
$operating_table  : string
$output_type  : string|null
$part_of_id  : int|null
$relative_name  : string|null
$run  : bool|null
$script  : string|null
$script_ext  : string|null
$script_file_name  : string|null
$script_type  : string
$scripts_folder  : string
$system_node_type_id  : int|null
$system_node_type_name  : string|null
$type  : Type|null
$type_id  : int|null
$unsaved_props  : array<string|int, mixed>
$updated_timestamp  : string|null
$use_outputs_from_last_run  : bool|null
__construct()  : mixed
Node constructor.
__get()  : mixed
If the property is an attribute, then return the attribute object
__set()  : mixed
Set a property for this node, the value will not be saved until the 'save' method is called
__toString()  : string
Called during a print/echo statement, this function returns an html table of all the attributes of the Node, minus the DatabaseTrait properties
checkIfClassScript()  : mixed
set the is_constructor property
configErrorMessage()  : string
If the TiqConfig error message constant is set, use it otherwise return the 'last resort' error message.
delete()  : mixed
Delete by ID
generateRelativeName()  : string
getAllowedProps()  : array<string|int, mixed>
Get the allowed properties for this Node
getAttributeCount()  : Node
Gets the total attribute count of the given node
getAttributes()  : $this
Queries attributes for a given node add attaches it to the node object.
getChildren()  : $this
This function fetches all the nodes one level down
getConfig()  : TiqConfig
getDb()  : PgSQL
Get database instance
getDisplayScript()  : array<string|int, mixed>
Gets the Display scripts associate to this node, will search inheritance path as well as type
getFQN()  : string
Returns a human readable FQN UnitTest Path: test/Model/AttributeTest.php/testInsertAndGetFqn()
getFQNDisplayPath()  : mixed
This is a bulk call of the function below getFQN
getIdFromFileName()  : string
extracts ID from [relative_name]_[ID].[file_extension]
getInstance()  : Node
getLibrary()  : mixed
getNodeId()  : int
Return the ID from and FQN
getNodeSet()  : array<string|int, mixed>
Returns a list of all nodes that are for type $identifier to get the type name use "SELECT * FROM model.system_node_types"
getOperatingTable()  : string
Returns the current operating table
getParent()  : $this
This function fetches all the nodes one level up
getRelationshipsDown()  : Node
Gets all direct children nodes
getRelationshipsUp()  : Node
Gets all direct parent nodes
getScripts()  : Node
Gets the scripts associate to this node
getSystemType()  : Node
Sets the system type name of the given attribute
getTaxonomySystemNodeTypeId()  : int
getTemplate()  : Script
Return template
getTemplates()  : mixed
Returns all templates
getType()  : mixed
hasClassScript()  : bool
Checks all of the nodes' script to see if there is a class script
include()  : mixed
includeScript()  : bool
Acts as a 'include_once' for a script based on an FQN.
isDebug()  : bool
Is debug mode or not
jsonSerialize()  : array<string|int, mixed>
Typically used to create a structure that js can turn into an object in the browser minus the DatabaseTrait properties
reduceFQN()  : array<string|int, string>
save()  : mixed
writes updated properties into the database, or creates the node if it does not exist
saveScript()  : mixed
Saves a script on disk.
convertPostgresTypeArray()  : array<string|int, mixed>
Take a postgres typed array and converts it to a php array i.g. {"test 1","test 2"} from postgres will yeild ["test 1", "test 2"]
deleteScriptFromDisk()  : mixed
This function may not need to exist, but we might want protection in the future?.
getTypeName()  : string
This should be replaced by attaching a Type object to the node.
saveToDisk()  : mixed
Save a file on disk with specific permissions
setProps()  : mixed
Loads all database columns as static variables. To load a variable, it must exist in the class.

Constants

EDIT_STATUS

public mixed EDIT_STATUS = [0 => '', 1 => 'In Work', 2 => 'In Review', 3 => 'Approved', 4 => 'Done']

Properties

$attributes

public array<string|int, mixed> $attributes = array()

$children

public array<string|int, mixed> $children = array()

$db_config

Config instance

public static TiqConfig $db_config = null

$debug

Is debug mode or not

public static bool $debug = false

$description

public string $description

$display_name

public string $display_name

$error_message

Base error message, this belongs in com_think's configuration class

public static mixed $error_message = 'An issue occurred, please contact ThinkIQ for Support and enable debugging'

$is_class_script

public bool $is_class_script = false

$nodes

public array<string|int, mixed> $nodes = array()

$relationshipsDown

public array<string|int, mixed> $relationshipsDown = array()

$relationshipsUp

public array<string|int, mixed> $relationshipsUp = array()

$relative_name

public string $relative_name

$script_type

public string $script_type

$scripts

public array<string|int, mixed> $scripts = array()

$system_node_type_id

public int $system_node_type_id

$totalAttributes

public int|null $totalAttributes = null

$totalScripts

public int|null $totalScripts = null

$allowed_props

protected array<string|int, mixed> $allowed_props = array()

$called_constructor

protected bool $called_constructor = false

$class_script

protected Script|null $class_script = null

$created_timestamp

protected string|null $created_timestamp = null

$cron_expression

protected string|null $cron_expression = null

$description

protected string|null $description = null

$display_name

protected string|null $display_name = null

$display_path

protected string|null $display_path = null

$document

protected string|null $document = null

$edit_status

protected string|null $edit_status = null

$fqn

protected string|null $fqn = ''

$id

protected int|null $id = null

$id_path

protected string|null $id_path = ''

$initial_inputs

protected string|null $initial_inputs = null

$is_root

protected bool|null $is_root = null

$max_acceptable_run_secs

protected int|null $max_acceptable_run_secs = null

$operating_table

protected string $operating_table = 'scripts'

$output_type

protected string|null $output_type = null

$part_of_id

protected int|null $part_of_id = null

$relative_name

protected string|null $relative_name = null

$run

protected bool|null $run = null

$script

protected string|null $script = null

$script_ext

protected string|null $script_ext = null

$script_file_name

protected string|null $script_file_name = null

$script_type

protected string $script_type = ''

$scripts_folder

protected string $scripts_folder = ''

$system_node_type_id

protected int|null $system_node_type_id = null

$system_node_type_name

protected string|null $system_node_type_name = null

$type_id

protected int|null $type_id = null

$unsaved_props

protected array<string|int, mixed> $unsaved_props = array()

$updated_timestamp

protected string|null $updated_timestamp = null

$use_outputs_from_last_run

protected bool|null $use_outputs_from_last_run = null

Methods

__construct()

Node constructor.

public __construct([mixed $identifier = null ][, array<string|int, mixed> $config = [] ][, array<string|int, mixed> $additionalMethods = [] ]) : mixed
Parameters
$identifier : mixed = null

mixed FQN or ID

$config : array<string|int, mixed> = []
$additionalMethods : array<string|int, mixed> = []
Return values
mixed

__get()

If the property is an attribute, then return the attribute object

public __get( $name) : mixed
Parameters
$name :
Return values
mixed

__set()

Set a property for this node, the value will not be saved until the 'save' method is called

public __set(string $prop, mixed $value) : mixed
Parameters
$prop : string
$value : mixed
Return values
mixed

__toString()

Called during a print/echo statement, this function returns an html table of all the attributes of the Node, minus the DatabaseTrait properties

public __toString() : string
Return values
string

checkIfClassScript()

set the is_constructor property

public checkIfClassScript() : mixed
Return values
mixed

configErrorMessage()

If the TiqConfig error message constant is set, use it otherwise return the 'last resort' error message.

public static configErrorMessage() : string
Return values
string

delete()

Delete by ID

public delete() : mixed
Tags
throws
Exception
Return values
mixed

generateRelativeName()

public static generateRelativeName(string $displayName[, string|null $typeName = null ][, int|null $partOfId = null ][, int|null $nodeId = null ]) : string
Parameters
$displayName : string
$typeName : string|null = null
$partOfId : int|null = null
$nodeId : int|null = null
Return values
string

getAllowedProps()

Get the allowed properties for this Node

public getAllowedProps() : array<string|int, mixed>

Return an array intersection of the Class Properties and Table Columns

Return values
array<string|int, mixed>

getAttributeCount()

Gets the total attribute count of the given node

public getAttributeCount([string|null $search_params = null ][, false $deep_search = false ][, false $show_hidden_attributes = true ]) : Node
Parameters
$search_params : string|null = null

This parameter is a JSON object

$deep_search : false = false

This toggles the ability to search not only immediate children but children of children

$show_hidden_attributes : false = true
Return values
Node

getAttributes()

Queries attributes for a given node add attaches it to the node object.

public getAttributes([string $column = 'display_name' ][, string $order = 'ASC' ][, int|null $limit = null ][, int|null $offset = null ][, string|null $search_params = null ][, bool $deep_search = false ][, false $show_hidden_attributes = true ][, string $default_selected_ids = "" ]) : $this
Parameters
$column : string = 'display_name'

This is the name of the column we order by

$order : string = 'ASC'
$limit : int|null = null
$offset : int|null = null
$search_params : string|null = null

This parameter is a JSON object

$deep_search : bool = false

This toggles the ability to search not only immediate children but children of children

$show_hidden_attributes : false = true
$default_selected_ids : string = ""
Tags
throws
Exception
Return values
$this

getChildren()

This function fetches all the nodes one level down

public getChildren([array<string|int, mixed> $additionalMethods = [] ]) : $this
Parameters
$additionalMethods : array<string|int, mixed> = []
Tags
throws
Exception
Return values
$this

getConfig()

public static getConfig() : TiqConfig
Return values
TiqConfig

getDisplayScript()

Gets the Display scripts associate to this node, will search inheritance path as well as type

public static getDisplayScript(int $id) : array<string|int, mixed>
Parameters
$id : int
Tags
throws
Exception
Return values
array<string|int, mixed>

getFQN()

Returns a human readable FQN UnitTest Path: test/Model/AttributeTest.php/testInsertAndGetFqn()

public getFQN([string $delimiter = '.' ][, bool $use_display_names = false ]) : string
Parameters
$delimiter : string = '.'

optional parameter to separate the relative names

$use_display_names : bool = false

optional parameter to return display names instead of relative names

Tags
throws
Exception
Return values
string

getFQNDisplayPath()

This is a bulk call of the function below getFQN

public static getFQNDisplayPath(array<string|int, mixed> $ids[, string $delimiter = '.' ][, bool $reduce = true ]) : mixed
Parameters
$ids : array<string|int, mixed>
$delimiter : string = '.'
$reduce : bool = true
Return values
mixed

getIdFromFileName()

extracts ID from [relative_name]_[ID].[file_extension]

public static getIdFromFileName(string $script_file_name) : string

take something like my_script_for_something_31412.php and return 31412 flow: [relative_name][ID].[file_extension] => [relative_name][ID] => [ID]

Parameters
$script_file_name : string
Return values
string

getInstance()

public static getInstance(mixed $identifier[, array<string|int, mixed>|null $config = [] ]) : Node
Parameters
$identifier : mixed

could be an FQN or ID

$config : array<string|int, mixed>|null = []
Tags
throws
Exception
Return values
Node

getLibrary()

public getLibrary() : mixed
Tags
throws
Exception
Return values
mixed

getNodeId()

Return the ID from and FQN

public static getNodeId(string $identifier) : int
Parameters
$identifier : string

FQN or ID

Tags
throws
Exception
Return values
int

getNodeSet()

Returns a list of all nodes that are for type $identifier to get the type name use "SELECT * FROM model.system_node_types"

public static getNodeSet(string $identifier[, string $column = 'display_name' ][, string $order = 'ASC' ][, int|null $limit = null ][, int|null $offset = null ][, string|null $search_params = null ][, string $default_selected_ids = "" ][, bool|null $deep_search = false ][, array<string|int, mixed> $additionalMethods = [] ]) : array<string|int, mixed>
Parameters
$identifier : string

type_name or ID

$column : string = 'display_name'
$order : string = 'ASC'
$limit : int|null = null
$offset : int|null = null
$search_params : string|null = null
$default_selected_ids : string = ""
$deep_search : bool|null = false
$additionalMethods : array<string|int, mixed> = []
Tags
throws
Exception
Return values
array<string|int, mixed>

getOperatingTable()

Returns the current operating table

public getOperatingTable() : string
Return values
string

getParent()

This function fetches all the nodes one level up

public getParent([array<string|int, mixed> $additionalMethods = [] ]) : $this
Parameters
$additionalMethods : array<string|int, mixed> = []
Tags
throws
Exception
Return values
$this

getRelationshipsDown()

Gets all direct children nodes

public getRelationshipsDown() : Node
Return values
Node

getRelationshipsUp()

Gets all direct parent nodes

public getRelationshipsUp() : Node
Return values
Node

getScripts()

Gets the scripts associate to this node

public getScripts() : Node
Tags
throws
Exception
Return values
Node

getSystemType()

Sets the system type name of the given attribute

public getSystemType() : Node
Return values
Node

getTaxonomySystemNodeTypeId()

public static getTaxonomySystemNodeTypeId( $id) : int
Parameters
$id :
Return values
int

getTemplate()

Return template

public static getTemplate(string|int|Script $identifier) : Script
Parameters
$identifier : string|int|Script
Tags
throws
Exception
Return values
Script

getTemplates()

Returns all templates

public static getTemplates() : mixed
Return values
mixed

getType()

public getType() : mixed
Tags
throws
Exception
Return values
mixed

hasClassScript()

Checks all of the nodes' script to see if there is a class script

public hasClassScript() : bool
Tags
throws
Exception
Return values
bool

include()

public include() : mixed
Tags
throws
Exception
Return values
mixed

includeScript()

Acts as a 'include_once' for a script based on an FQN.

public static includeScript(string|int|Script $identifier[, null $node_id = null ]) : bool

Note that this is checking the file system, so even though a script may be declared in the database, that does not mean it has been saved to the file system yet.

Parameters
$identifier : string|int|Script

This can also be the id of the script, fqn, or object. The intent is for an FQN to be used.

$node_id : null = null

This is the instance the script is running on

Tags
throws
Exception
Return values
bool

isDebug()

Is debug mode or not

public static isDebug() : bool
Return values
bool

jsonSerialize()

Typically used to create a structure that js can turn into an object in the browser minus the DatabaseTrait properties

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

reduceFQN()

public static reduceFQN(array<string|int, mixed> $paths, string $delimiter) : array<string|int, string>
Parameters
$paths : array<string|int, mixed>
$delimiter : string
Return values
array<string|int, string>

save()

writes updated properties into the database, or creates the node if it does not exist

public save() : mixed
Tags
throws
PDOException
Return values
mixed

saveScript()

Saves a script on disk.

public static saveScript(string $script_file_name[, string $scripts_folder = '' ]) : mixed
  1. Make sure the script exists in the database, if no delete from disk
  2. Script is in DB, create on disk
Parameters
$script_file_name : string
$scripts_folder : string = ''
Tags
throws
Exception
Return values
mixed

convertPostgresTypeArray()

Take a postgres typed array and converts it to a php array i.g. {"test 1","test 2"} from postgres will yeild ["test 1", "test 2"]

protected convertPostgresTypeArray( $data) : array<string|int, mixed>
Parameters
$data :
Return values
array<string|int, mixed>

deleteScriptFromDisk()

This function may not need to exist, but we might want protection in the future?.

protected static deleteScriptFromDisk(Script $script) : mixed

..

Parameters
$script : Script
Tags
throws
Exception
Return values
mixed

getTypeName()

This should be replaced by attaching a Type object to the node.

protected getTypeName() : string

..

Return values
string

saveToDisk()

Save a file on disk with specific permissions

protected static saveToDisk(string $script_file_name, string $content) : mixed
Parameters
$script_file_name : string
$content : string
Tags
throws
Exception
Return values
mixed

setProps()

Loads all database columns as static variables. To load a variable, it must exist in the class.

protected setProps([array<string|int, mixed> $config = [] ][, array<string|int, mixed> $additionalMethods = [] ]) : mixed

If the 'id' property is not set, we still run this function, populating the $allowed_props variable

Parameters
$config : array<string|int, mixed> = []

This array contains the same properties as a record from the corresponding table in the database

$additionalMethods : array<string|int, mixed> = []
Return values
mixed

Search results