-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.php
More file actions
49 lines (36 loc) · 1.08 KB
/
Plugin.php
File metadata and controls
49 lines (36 loc) · 1.08 KB
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
45
46
47
48
49
<?php
namespace TypechoPlugin\ZaoApi;
// 定义 DEBUG 常量(开发环境设为 true,生产环境设为 false)
defined('DEBUG') or define('DEBUG', true); // 建议根据环境动态切换
use Typecho\Plugin\PluginInterface;
use Typecho\Widget\Helper\Form;
use TypechoPlugin\ZaoApi\Api;
use TypechoPlugin\ZaoApi\Util\Database;
if (!defined('__TYPECHO_ROOT_DIR__')) {
exit;
}
/**
* ZaoApi 提供完整 RESTful API 的插件
*
* @package ZaoApi
* @author Zao`ss
* @version 2.1.0
* @link https://github.com/guugg/ZaoApi
*/
class Plugin implements PluginInterface
{
public static function activate()
{
// 执行数据库迁移
$migrateResults = Database::migrate();
// 只注册“路由分发类”(根目录 ZaoApi\Api.php)
Routes::registerByAttributes([Api::class]);
return 'ZaoApi插件激活成功!' . PHP_EOL . implode(PHP_EOL, $migrateResults);
}
public static function deactivate()
{
Routes::unregisterByAttributes([Api::class]);
}
public static function config(Form $form) {}
public static function personalConfig(Form $form) {}
}