@@ 17-50 (lines=34) @@ | ||
14 | /** |
|
15 | * An action that simply echo's data. |
|
16 | */ |
|
17 | final class EchoAction extends AbstractAction |
|
18 | { |
|
19 | /** The constant that defines the output socket. */ |
|
20 | const SOCKET_OUTPUT = 'out'; |
|
21 | ||
22 | /** The socket that holds the data variable. */ |
|
23 | const SOCKET_DATA = 'data'; |
|
24 | ||
25 | /** |
|
26 | * Initializes a new instance of this class. |
|
27 | */ |
|
28 | public function __construct() |
|
29 | { |
|
30 | parent::__construct(); |
|
31 | ||
32 | $this->createSocket(self::SOCKET_OUTPUT); |
|
33 | $this->createSocket(self::SOCKET_DATA); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * Executes the node's logic. |
|
38 | */ |
|
39 | public function execute() |
|
40 | { |
|
41 | $node = $this->getSocket(self::SOCKET_DATA)->getNode(0); |
|
42 | if ($node === null || $node->getValue() === null) { |
|
43 | throw new \InvalidArgumentException('There is no data set.'); |
|
44 | } |
|
45 | ||
46 | echo $node->getValue(); |
|
47 | ||
48 | $this->activate(self::SOCKET_OUTPUT); |
|
49 | } |
|
50 | } |
|
51 |
@@ 17-50 (lines=34) @@ | ||
14 | /** |
|
15 | * An action that var_dumps the bound value. |
|
16 | */ |
|
17 | final class PrintRAction extends AbstractAction |
|
18 | { |
|
19 | /** The constant that defines the output socket. */ |
|
20 | const SOCKET_OUTPUT = 'out'; |
|
21 | ||
22 | /** The socket that holds the data variable. */ |
|
23 | const SOCKET_DATA = 'data'; |
|
24 | ||
25 | /** |
|
26 | * Initializes a new instance of this class. |
|
27 | */ |
|
28 | public function __construct() |
|
29 | { |
|
30 | parent::__construct(); |
|
31 | ||
32 | $this->createSocket(self::SOCKET_OUTPUT); |
|
33 | $this->createSocket(self::SOCKET_DATA); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * Executes the node's logic. |
|
38 | */ |
|
39 | public function execute() |
|
40 | { |
|
41 | $node = $this->getSocket(self::SOCKET_DATA)->getNode(0); |
|
42 | if ($node === null || $node->getValue() === null) { |
|
43 | throw new \InvalidArgumentException('There is not data set.'); |
|
44 | } |
|
45 | ||
46 | print_r($node->getValue()); |
|
47 | ||
48 | $this->activate(self::SOCKET_OUTPUT); |
|
49 | } |
|
50 | } |
|
51 |