PluginsBase.php 600 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace app;
  3. use think\App;
  4. use think\View;
  5. class PluginsBase extends BaseController
  6. {
  7. public ?View $view = null;
  8. function __construct(App $app)
  9. {
  10. parent::__construct($app);
  11. $this->_initialize();
  12. }
  13. function _initialize()
  14. {
  15. $this->view = new View($this->app);
  16. }
  17. function assign($key, $view)
  18. {
  19. $this->view->assign($key, $view);
  20. }
  21. function fetch($view, $opt = []): string
  22. {
  23. $view = plugins_path("view/" . $view);
  24. return $this->view->fetch($view, $opt);
  25. }
  26. }