script\PHPCode - edoc automate
Die PHPCode-Aktion führt einen PHP-Code aus. Die Daten (SingleValue oder Dataset) werden über die API-Funktion zurückgegeben. Wichtig: Jede Aktion wird in einem separaten Kontext ausgeführt, sodass kein Zugriff auf temporäre Daten, Variablen usw. zwischen Aktionen besteht. Beispiel ```php <?php use edoc\appserver\ScriptAPI\Action; $data = []; $value = 123; $i = 0; $value = Action::getInstance()->exec('GetValue', ['rows']); for($i = 0; $i < $value; $i++) { $data[] = [ 'value1' => $i, 'value2' => 'col2: '.$i ]; } Action::getInstance()->returnDataset($data); ``` Script API ```php class Action { // creates a new instance public static function getInstance(); // Executes an action. // @param string $actionName Type of action, e.g. default\\Message. // @param array $params Parameter for the selected action. public function exec($actionName, $params); // Get datasource instance (d.3/db/...) // @param $name // @return DataSource|null public function getDatasource($name): ?DataSource; // Sets return value of the callback. If called several times, the previous value will be overwritten! // @param string|int|boolean $value The return value. public function returnValue($value); // Sets the return dataset of the callback. If called several times, the previous value will be overwritten! // @param array $value The return dataset. public function returnDataset($value); // Returns information about the current app. // @return array public function info(); // Returns all app variables. // @return array public function getAppVariables(); // Returns the app variable with the name $name. // @return mixed public function getAppVariable($name); } ```
Parameter
Typ | Name | Beschreibung |
---|---|---|
EDITOR | code | Gibt den auszuführenden PHP-Code an. |
Rückgabe
Typ | Beschreibung |
---|---|
SINGLEVALUE | Gibt den Wert des Callbacks zurück. |
DATASET | Gibt den Datensatz des Callbacks zurück. |