Skip to content

Commit 90c43b8

Browse files
committed
Add lazy component init
1 parent ea85a34 commit 90c43b8

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace WebApp\Component;
4+
5+
/** Component that has a special method that will be called immediately before rendering */
6+
interface LazyInitializer {
7+
8+
public function lazyInit();
9+
}

src/WebApp/Theme.php

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public function renderComponent($component) {
107107
}
108108
return $rc;
109109
} else if (is_object($component)) {
110+
if (is_a($component, 'WebApp\\Component\\LazyInitializer')) {
111+
$component->lazyInit();
112+
}
110113
return $this->getRenderer($component)->render();
111114
}
112115
return '';

0 commit comments

Comments
 (0)