1 <?php
2
3
4 // eg. reusing the a domain like in the examples, NOT in ADR.
5 // eg. commandline
6 //
7 // I'd think every call to __invoke would return a NEW payload
8 //
9 // Right? Since the Payload is a "Domain Payload", not an "ADR Action Payload"
10
11 class DomainEdit
12 {
13 // Shouldn't the Domain get a Payload FACTORY so every call returns a new
14 // Payload?
15 public function __invoke($input)
16 {
17
18 if (! $input) {
19 return $this->payload
20 ->setStatus(Payload::NOT_VALID)
21 ->setInput($input)
22 ->setMessages(['error' => 'Input not set.']);
23 }
24
25 $result = $this->doStuff($input);
26
27 return $this->payload
28 ->setStatus(Payload::UPDATED)
29 ->setOutput($result);
30 }
31 }
32
33
34 class SomeOtherNotADRThing
35 {
36 // eg. What if somehting uses the domain in a loop?
37 public function __invoke($args)
38 {
39 $results = [];
40 foreach ($args as $data)
41 {
42 $result = $this->domain->__invoke($data);
43 if ($messages = $result->getMessages()) {
44 $this->doSomthingWithMessages($messages);
45 }
46 $results[] = $result;
47 }
48
49 return $results;
50 }
51 }