Conditions | 6 |
Paths | 2 |
Total Lines | 28 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | public function mountBlocks($content, array $blocks) |
||
23 | { |
||
24 | if (preg_match_all('/ node:attributes(?:=\"([^\'"]+)\")?/i', $content, $matches)) { |
||
25 | //We have to sort from longest to shortest |
||
26 | uasort($matches[0], function ($replaceA, $replaceB) { |
||
27 | return strlen($replaceB) - strlen($replaceA); |
||
28 | }); |
||
29 | |||
30 | foreach ($matches[0] as $id => $replace) { |
||
31 | $inject = []; |
||
32 | |||
33 | //That's why we need longest first (prefix mode) |
||
34 | foreach ($this->filterBlocks($matches[1][$id], $blocks) as $name => $value) { |
||
35 | if ($value === null) { |
||
36 | $inject[$name] = $name; |
||
37 | continue; |
||
38 | } |
||
39 | |||
40 | $inject[$name] = $name . '="' . $value . '"'; |
||
41 | } |
||
42 | |||
43 | //Injecting |
||
44 | $content = str_replace($replace, $inject ? ' ' . join(' ', $inject) : '', $content); |
||
45 | } |
||
46 | } |
||
47 | |||
48 | return $content; |
||
49 | } |
||
50 | } |