| Conditions | 6 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function init(): void |
||
| 16 | { |
||
| 17 | $richtextResolver = new Resolver(); |
||
| 18 | |||
| 19 | $content = []; |
||
| 20 | |||
| 21 | // Loop through all the nodes looking for a ‘blok’ nodes and convery them to |
||
| 22 | // the correct Block Class. All other nodes are converted to HTML |
||
| 23 | foreach ($this->content['content'] as $node) { |
||
| 24 | if ($node['type'] === 'blok' && isset($node['attrs']['body']) && is_array($node['attrs']['body'])) { |
||
| 25 | foreach ($node['attrs']['body'] as $blockContent) { |
||
| 26 | $class = $this->getChildClassName('Block', $blockContent['component']); |
||
| 27 | $block = new $class($blockContent, $this->block()); |
||
| 28 | |||
| 29 | $content[] = $block; |
||
| 30 | } |
||
| 31 | } else { |
||
| 32 | $content[] = $richtextResolver->render(["content" => [$node]]); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->content = collect($content); |
||
|
|
|||
| 37 | } |
||
| 59 | } |