Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
actionschain.php
1<?php
2namespace Bitrix\Scale;
3
9{
10 protected $id = "";
11 protected $userParams = array();
12 protected $freeParams = array();
13 protected $actionParams = array();
14 protected $resultData = array();
15
16 protected $serverHostname = "";
17
18 public $results = [];
19
29 public function __construct($actionId, $actionParams, $serverHostname = "", $userParams = array(), $freeParams = array())
30 {
31 if($actionId == '')
32 throw new \Bitrix\Main\ArgumentNullException("actionId");
33
34 if(!is_array($actionParams) || empty($actionParams))
35 throw new \Exception("Params of action ".$actionId." are not defined correctly!");
36
37 if(!isset($actionParams["ACTIONS"]) || !is_array($actionParams["ACTIONS"]))
38 throw new \Exception("Required param ACTIONS of action ".$actionId." are not defined!");
39
40 if(!is_array($userParams))
41 throw new \Bitrix\Main\ArgumentTypeException("userParams", "array");
42
43 if(!is_array($freeParams))
44 throw new \Bitrix\Main\ArgumentTypeException("freeParams", "array");
45
46 $this->id = $actionId;
47 $this->userParams = $userParams;
48 $this->freeParams = $freeParams;
49 $this->actionParams = $actionParams;
50 $this->serverHostname = $serverHostname;
51 }
52
53 public function getResult()
54 {
55 return $this->results;
56 }
57
58 public function getActionObj($actionId)
59 {
60 return ActionsData::getActionObject($actionId, $this->serverHostname, $this->userParams, $this->freeParams);
61 }
62
63 public function start($inputParams = array())
64 {
65 if(!is_array($inputParams))
66 throw new \Bitrix\Main\ArgumentTypeException("inputParams", "array");
67
68 $result = true;
69
70 foreach($this->actionParams["ACTIONS"] as $actionId)
71 {
72 $action = $this->getActionObj($actionId);
73
74 if(!$action->start($inputParams))
75 $result = false;
76
77 $arRes = $action->getResult();
78
79 foreach($arRes as $actId => $res)
80 $this->results[$actId] = $res;
81
82 if(!$result)
83 break;
84
85 if(isset($arRes[$actionId]["OUTPUT"]["DATA"]["params"]) && is_array($arRes[$actionId]["OUTPUT"]["DATA"]["params"]))
86 foreach($arRes[$actionId]["OUTPUT"]["DATA"]["params"] as $paramId => $paramValue)
87 if(!isset($inputParams[$paramId]))
88 $inputParams[$paramId] = $paramValue;
89 }
90
91 return $result;
92 }
93}
start($inputParams=array())
__construct($actionId, $actionParams, $serverHostname="", $userParams=array(), $freeParams=array())
static getActionObject( $actionId, $serverHostname="", array $userParams=[], array $freeParams=[], array $actionParams=[])