50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?php
|
||
// +------------------------------------------------+
|
||
// |http://www.cjango.com |
|
||
// +------------------------------------------------+
|
||
// | 修复BUG不是一朝一夕的事情,等我喝醉了再说吧! |
|
||
// +------------------------------------------------+
|
||
// | Author: 小陈叔叔 <Jason.Chen> |
|
||
// +------------------------------------------------+
|
||
namespace tools;
|
||
|
||
use think\Request;
|
||
|
||
class Behavior
|
||
{
|
||
|
||
/**
|
||
* 加载系统配置
|
||
*/
|
||
public function appBegin()
|
||
{
|
||
Config::load();
|
||
define('__SELF__', Request::instance()->url(true));
|
||
}
|
||
|
||
/**
|
||
* 定义系统常量
|
||
*/
|
||
public function moduleInit()
|
||
{
|
||
$request = Request::instance();
|
||
$method = $request->method();
|
||
|
||
define('IS_GET', $method == 'GET' ? true : false);
|
||
define('IS_POST', $method == 'POST' ? true : false);
|
||
define('IS_AJAX', $request->isAjax());
|
||
|
||
define('MODULE_NAME', $request->module());
|
||
define('CONTROLLER_NAME', $request->controller());
|
||
define('ACTION_NAME', $request->action());
|
||
}
|
||
|
||
/**
|
||
* 返回头修改
|
||
*/
|
||
public function appEnd(&$response)
|
||
{
|
||
$response->header('X-Powered-By', 'cjango.com');
|
||
}
|
||
}
|