Closed vjik closed 2 years ago
For example, this class convient use in widgets:
final class SidebarMenu extends Widget { public function __construct( private View $view ) { $this->view = $this->view->withContext(new ViewContext(__DIR__)); } protected function run(): string { return $this->view->render('menu'); } }
or so:
final class SidebarMenu extends Widget { public function __construct( private View $view ) { $this->view = $this->view->withContextPath(__DIR__); } protected function run(): string { return $this->view->render('menu'); } }
This is better, than:
final class SidebarMenu extends Widget implements ViewContextInterface { public function __construct( private View $view ) { $this->view = $this->view->withContext($this); } protected function run(): string { return $this->view->render('menu'); } public function getViewPath(): string { return __DIR__; } }
For example, this class convient use in widgets:
or so:
This is better, than: