1: <?php
2:
3: declare(strict_types=1);
4:
5: namespace Atk4\Ui\UserAction;
6:
7: use Atk4\Core\WarnDynamicPropertyTrait;
8: use Atk4\Ui\AbstractView;
9: use Atk4\Ui\Js\JsBlock;
10:
11: class SharedExecutor
12: {
13: use WarnDynamicPropertyTrait;
14:
15: /** @var AbstractView&ExecutorInterface */
16: private ExecutorInterface $executor;
17:
18: /**
19: * @param AbstractView&ExecutorInterface $executor
20: */
21: public function __construct(ExecutorInterface $executor)
22: {
23: $this->executor = $executor;
24: }
25:
26: /**
27: * @return AbstractView&ExecutorInterface
28: */
29: public function getExecutor(): ExecutorInterface
30: {
31: return $this->executor;
32: }
33:
34: /**
35: * @param array<string, string> $urlArgs
36: */
37: public function jsExecute(array $urlArgs): JsBlock
38: {
39: // TODO executor::jsExecute() should be called only once, registered as a custom jQuery event and then
40: // call the event from JS with arguments to improve performance, ie. render (possibly large) JS only once
41: return $this->getExecutor()->jsExecute($urlArgs); // @phpstan-ignore-line
42: }
43: }
44: