2022-05-24 10:02:39 +02:00
|
|
|
<?php
|
|
|
|
include_once APP . 'Model/WorkflowModules/WorkflowBaseModule.php';
|
|
|
|
|
2022-07-20 15:06:41 +02:00
|
|
|
class Module_push_zmq extends WorkflowBaseActionModule
|
2022-05-24 10:02:39 +02:00
|
|
|
{
|
2022-07-19 09:52:38 +02:00
|
|
|
public $blocking = false;
|
2022-05-24 10:02:39 +02:00
|
|
|
public $id = 'push-zmq';
|
|
|
|
public $name = 'Push to ZMQ';
|
|
|
|
public $description = 'Push to the ZMQ channel';
|
2022-06-21 10:01:28 +02:00
|
|
|
public $icon_path = 'zeromq.png';
|
2022-05-24 10:02:39 +02:00
|
|
|
public $inputs = 1;
|
2022-05-31 11:58:18 +02:00
|
|
|
public $outputs = 1;
|
2022-05-24 10:02:39 +02:00
|
|
|
public $params = [];
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->params = [
|
2022-05-26 10:59:28 +02:00
|
|
|
[
|
2022-08-04 13:34:50 +02:00
|
|
|
'id' => 'data_extraction_path',
|
|
|
|
'label' => 'Data extraction path',
|
2022-07-27 15:41:21 +02:00
|
|
|
'type' => 'input',
|
2022-06-01 09:57:57 +02:00
|
|
|
'default' => '',
|
2022-06-10 16:11:47 +02:00
|
|
|
'placeholder' => 'Attribute.{n}.AttributeTag.{n}.Tag.name',
|
2022-06-01 09:57:57 +02:00
|
|
|
],
|
2022-05-24 10:02:39 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2022-05-30 14:34:45 +02:00
|
|
|
public function exec(array $node, WorkflowRoamingData $roamingData, array &$errors=[]): bool
|
2022-05-24 10:02:39 +02:00
|
|
|
{
|
2022-05-30 14:34:45 +02:00
|
|
|
parent::exec($node, $roamingData, $errors);
|
2022-05-26 10:59:28 +02:00
|
|
|
$params = $this->getParamsWithValues($node);
|
2022-07-27 15:41:21 +02:00
|
|
|
$path = $params['match_condition']['value'];
|
2022-06-10 16:11:47 +02:00
|
|
|
$data = $roamingData->getData();
|
|
|
|
$extracted = $this->extractData($data, $path);
|
|
|
|
if ($extracted === false) {
|
|
|
|
$errors[] = __('Error while trying to extract data with path `%s`', $path);
|
|
|
|
return false;
|
2022-06-01 09:57:57 +02:00
|
|
|
}
|
2022-07-25 15:08:17 +02:00
|
|
|
$this->push_zmq(JsonTool::encode($extracted));
|
2022-06-01 09:57:57 +02:00
|
|
|
return true;
|
2022-05-24 10:02:39 +02:00
|
|
|
}
|
|
|
|
}
|