@@ 9-19 (lines=11) @@ | ||
6 | use const einfach\operation\response\RESPONSE_TYPE_OK; |
|
7 | use const einfach\operation\response\RESPONSE_TYPE_ERROR; |
|
8 | ||
9 | class Always extends AbstractStep |
|
10 | { |
|
11 | public function __invoke(&$params, string $track) |
|
12 | { |
|
13 | $response = $this->normalizeStepResponse(call_user_func($this->function, $params)); |
|
14 | // run on any track, but not change it to OK, if strated on Error |
|
15 | $type = ($track == Railway::TRACK_FAILURE) ? RESPONSE_TYPE_ERROR : $response['type']; |
|
16 | $response['type'] = $type; |
|
17 | return $response; |
|
18 | } |
|
19 | } |
|
20 |
@@ 8-23 (lines=16) @@ | ||
5 | use einfach\operation\Railway; |
|
6 | use const einfach\operation\response\RESPONSE_TYPE_ERROR; |
|
7 | ||
8 | class Failure extends AbstractStep |
|
9 | { |
|
10 | public function __invoke(&$params, string $track) |
|
11 | { |
|
12 | // works only on Error track |
|
13 | if ($track == Railway::TRACK_FAILURE) { |
|
14 | $response = call_user_func($this->function, $params); |
|
15 | $response = $this->normalizeStepResponse($response); |
|
16 | // does not respect function return and always back to error track |
|
17 | $response['type'] = RESPONSE_TYPE_ERROR; |
|
18 | return $response; |
|
19 | } else { |
|
20 | $this->skip(); |
|
21 | } |
|
22 | } |
|
23 | } |
|
24 |