-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSend.php
More file actions
52 lines (43 loc) · 1.19 KB
/
Send.php
File metadata and controls
52 lines (43 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace App\Task;
use App\Model\ConnectionModel;
use App\Model\TaskModel;
use App\Service\ExecutionContext;
use App\Service\Webservices;
class Send extends TaskModel
{
public function __construct()
{
$this->type = 'request';
$this->name = 'Send';
$this->description = 'Send your data to your specific connection';
parent::__construct();
}
function getFields(): array
{
return [
'connection' => [
'label' => 'Connection',
'type' => 'entity',
'entity' => 'connection',
'config' => 'webservice',
'actions' => [ 'edit', 'create' ],
],
];
}
function execute( array $config, ExecutionContext $context, $data )
{
$connectionConfig = $config['connection'];
if ( ! empty( $connectionConfig['id'] ) ) {
$connection = ConnectionModel::get( $connectionConfig['id'] );
$result = $connection->handleSend( $connectionConfig, $data );
} else {
// @todo Custom webservice without Connection?
$webservice = Webservices::getWebservice( $connectionConfig['_class'] );
$result = $webservice->send( $connectionConfig, $data );
}
// @todo Option to include result in current dataset?
// @todo return type?
return $data;
}
}