-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathService.php
More file actions
44 lines (32 loc) · 836 Bytes
/
Service.php
File metadata and controls
44 lines (32 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace MerapiPanel\Module\Editor;
use MerapiPanel\Box\Module\__Fragment;
use MerapiPanel\Box\Module\Entity\Module;
use MerapiPanel\Views\View;
class Service extends __Fragment
{
protected Module $module;
function onCreate(Module $module)
{
$this->module = $module;
}
function onInit() {
View::getInstance()->getTwig()->addExtension(new EditorExtension());
}
// add other funstion here
public function findComponent($components, $type, $deep = 5)
{
foreach ($components as $component) {
if (isset($component['type']) && $component['type'] == $type) {
return $component;
}
if ($deep > 0 && isset($component['components'])) {
$component = $this->findComponent($component['components'], $type, $deep - 1);
if ($component) {
return $component;
}
}
}
return null;
}
}