如何使用PHP SDK在camunda中设置实例变量?

时间:2014-12-12 11:58:02

标签: php camunda

我正在尝试使用PHP SDK in camunda但是没有明确记录如何设置流程变量。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

您可以使用ProcessInstanceService

来实现

以下是演示发票收据的摘要。

$camundaAPI = new \org\camunda\php\sdk\Api('http://localhost:8080/engine-rest');
$processDefinitionRequest = new \org\camunda\php\sdk\entity\request\ProcessDefinitionRequest();
$processDefinitions = $camundaAPI->processDefinition->getDefinitions($processDefinitionRequest);

foreach($processDefinitions AS $pd) {
    echo 'Process deployment id: ' . $pd->getDeploymentId() . "\n";
}

// Process instance (make the assumption that $pd is the desired object).
$procInstance = $camundaAPI->processDefinition->startInstanceByKey($pd->getKey(), $processDefinitionRequest);

// ProcessInstanceService
$procInstanceService = new \org\camunda\php\sdk\service\ProcessInstanceService('http://localhost:8080/engine-rest/');
$var = new \org\camunda\php\sdk\entity\request\VariableRequest();
$var->setType('String');
$var->setValue('H4CK4THON2014');
$procInstanceService->putProcessVariable($procInstance->getId(), 'creditor', $var);