| Total Complexity | 5 |
| Total Lines | 34 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class ReplaceContent implements MutatorInterface, RenderableInterface |
||
| 18 | { |
||
| 19 | use RenderableTrait; |
||
| 20 | |||
| 21 | /** @var RenderBlock */ |
||
| 22 | private $renderBlock; |
||
| 23 | private $data = []; |
||
| 24 | |||
| 25 | public function __construct(RenderBlock $renderBlock) |
||
| 26 | { |
||
| 27 | $this->renderBlock = $renderBlock; |
||
| 28 | } |
||
| 29 | |||
| 30 | public function mutate(Handler $ajax): Handler |
||
| 31 | { |
||
| 32 | foreach ($this->data as $item) { |
||
| 33 | $block = $item['block']; |
||
| 34 | try { |
||
| 35 | $html = $this->renderBlock->render($block, $this->view, $this->parameters); |
||
| 36 | } catch (AjaxcomException $exception) { |
||
| 37 | continue; |
||
| 38 | } |
||
| 39 | |||
| 40 | $ajax->container($item['selector'])->html($html); |
||
| 41 | } |
||
| 42 | |||
| 43 | return $ajax; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function add(string $selector, string $blockId): self |
||
| 51 | } |
||
| 52 | } |
||
| 53 |