1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\UserAction;
6:
7: use Atk4\Data\Model\UserAction;
8:
9: /**
10: * ExecutorInterface can be implemented by a View that can be displayed on a page or in a modal window
11: * and it would have an interaction with the user before invoking Action's callback.
12: *
13: * SomeExecutor::addTo($app)->setAction($model, 'action_name');
14: *
15: * Here are some suggested implementation for ExecutorInterface:
16: * - MarkdownPreview. Requires $preview callback to be defined by the action. Will treat output as Markdown. Confirm button will
17: * execute action normally.
18: *
19: * - ArgumentForm. Displays a form which is populated with arguments. When submitting the form, action will be executed.
20: *
21: * - ArgumentForm\Preview. extends Argument form by adding a "Preview" area to the right of the form. By default will
22: * treat $preview as text, but can also use a more specific view, such as a Pie Chart
23: */
24: interface ExecutorInterface
25: {
26: // Generate UI which is presented to the user before action is executed
27: // https://github.com/php/php-src/pull/5708 protected methods cannot be defined in interface
28: // protected function init(): void;
29:
30: /**
31: * Will associate executor with the action.
32: *
33: * @return $this
34: */
35: public function setAction(UserAction $action);
36:
37: public function getAction(): UserAction;
38:
39: /**
40: * @return mixed
41: */
42: public function executeModelAction();
43: }
44: