edoc automate Guide

script\PHPCode - edoc automate

The PHPCode action executes a PHP code. The data (SingleValue or Dataset) is returned via the API function.

Important
Each action is executed in a separate context so that there is no access to temporary data, variables, etc. between actions.

Example

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);
}

Parameters

Type

Name

Description

EDITOR

code

Specifies the PHP code to be executed.

Return

Type

Description

SINGLEVALUE

Returns the value of the callback.

DATASET

Returns the record of the callback.

Last updated: