Files
BiveEngine/engine/class.plugin.php
2025-12-24 19:19:01 +03:00

36 lines
1.1 KiB
PHP

<?php
class Plugin {
public string $plugin_path; // Полный путь до плагина
public string $plugin_dir; // Папка плагина
public function __construct($plugin_dir)
{
$this->plugin_dir = $plugin_dir;
$this->plugin_path = $this->get_plugins_dir() . SLASH . $this->plugin_dir . SLASH;
}
public function get_plugins_dir() {
return ROOT_DIR . SLASH . PLAYAREA_DIR_NAME . SLASH . "plugins";
}
public function template_load($name, $variables = array(), $new = true)
{
global $b;
$plugin_template_path = $this->plugin_path . "template" . $name;
return $b->template_load_by_path($plugin_template_path, $variables, $new);
}
public function router_add($page, $func, $methods = array("GET", "POST"))
{
global $b;
$b->router_add($page, function () use ($func) { $func(); }, $methods);
}
public function get_assets_path(): string
{
global $b;
$root = $b->router_get_root_uri();
return $root . SLASH . PLAYAREA_DIR_NAME . SLASH . 'plugins' . SLASH . $this->plugin_dir . SLASH . "assets". SLASH;
}
}