-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
195165d
commit 54faedf
Showing
38 changed files
with
813 additions
and
796 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
|
||
namespace main\app\event; | ||
|
||
/** | ||
* 定义 Masterlab的事件 | ||
* @package main\app\event | ||
*/ | ||
final class Events | ||
{ | ||
|
||
/** | ||
* Private constructor. This class cannot be instantiated. | ||
*/ | ||
private function __construct() | ||
{ | ||
} | ||
|
||
public const postConnect = 'postConnect'; | ||
|
||
public const onIssueCreateBefore = 'onIssueCreateBefore'; | ||
public const onIssueCreateAfter = 'onIssueCreateAfter'; | ||
|
||
|
||
public const onSchemaCreateTableColumn = 'onSchemaCreateTableColumn'; | ||
public const onSchemaDropTable = 'onSchemaDropTable'; | ||
public const onSchemaAlterTable = 'onSchemaAlterTable'; | ||
public const onSchemaAlterTableAddColumn = 'onSchemaAlterTableAddColumn'; | ||
public const onSchemaAlterTableRemoveColumn = 'onSchemaAlterTableRemoveColumn'; | ||
public const onSchemaAlterTableChangeColumn = 'onSchemaAlterTableChangeColumn'; | ||
public const onSchemaAlterTableRenameColumn = 'onSchemaAlterTableRenameColumn'; | ||
public const onSchemaColumnDefinition = 'onSchemaColumnDefinition'; | ||
public const onSchemaIndexDefinition = 'onSchemaIndexDefinition'; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace main\app\event; | ||
|
||
use main\app\ctrl\BaseUserCtrl; | ||
use Symfony\Contracts\EventDispatcher\Event; | ||
use main\app\model\issue\IssueModel; | ||
|
||
/** | ||
* 系统全局设置的各种配置属性 | ||
* | ||
*/ | ||
class IssuePlacedEvent extends Event | ||
{ | ||
const NAME = 'issue.placed'; | ||
|
||
/** | ||
* @var BaseUserCtrl|null | ||
*/ | ||
protected $ctrl = null; | ||
|
||
/** | ||
* @var IssueModel | ||
*/ | ||
protected $issueModel; | ||
|
||
public function __construct(BaseUserCtrl $ctrl, IssueModel $issueModel) | ||
{ | ||
$this->ctrl = $ctrl; | ||
$this->issueModel = $issueModel; | ||
} | ||
|
||
/** | ||
* @return IssueModel | ||
*/ | ||
public function getIssueModel() | ||
{ | ||
return $this->issueModel; | ||
} | ||
|
||
/** | ||
* @return BaseUserCtrl|null | ||
*/ | ||
public function getCtrl() | ||
{ | ||
return $this->ctrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,54 @@ | ||
<?php | ||
/** | ||
* 项目统一加载文件 | ||
*/ | ||
* 项目统一加载文件 | ||
*/ | ||
|
||
|
||
// 项目文件根目录(文件系统,即本文件所在目录) | ||
define('APP_PATH', realpath(dirname(__FILE__)) . '/'); | ||
define('PRE_APP_PATH', realpath(dirname(__FILE__).'/../') . '/'); | ||
define('PRE_APP_PATH', realpath(dirname(__FILE__) . '/../') . '/'); | ||
|
||
// composer自动加载文件 | ||
require_once APP_PATH. '/../vendor/autoload.php'; | ||
require_once APP_PATH . '/../vendor/autoload.php'; | ||
|
||
// 加载自定义的函数库 | ||
include_once APP_PATH . 'function/autoload.php'; | ||
|
||
// 项目状态:deploy | development | ||
$appStatus = ""; | ||
$cacheYamlConfig = false; | ||
if (file_exists(PRE_APP_PATH . 'env.ini')) { | ||
$envArr = parse_ini_file(PRE_APP_PATH . 'env.ini'); | ||
$appStatus = $envArr['APP_STATUS']; | ||
$cacheYamlConfig = (boolean)$envArr['CACHE_YAML']; | ||
unset($envArr); | ||
} | ||
if (isset($_SERVER['APP_STATUS'])) { | ||
$appStatus = $_SERVER['APP_STATUS']; | ||
} | ||
define('APP_STATUS', $appStatus); | ||
|
||
// 加载主配置文件 config.yml | ||
// 加载主配置文件 config.yml @todo 使用yaml扩展函数将更高效 | ||
use Symfony\Component\Yaml\Yaml; | ||
$GLOBALS['_yml_config'] = Yaml::parseFile(PRE_APP_PATH.'config.'.$appStatus.'.yml'); | ||
$cacheYamlConfigFile = APP_PATH . 'storage/cache/config.yaml.php'; | ||
if ($cacheYamlConfig && file_exists($cacheYamlConfigFile)) { | ||
include $cacheYamlConfigFile; | ||
if (isset($_yaml_config) && !empty($_yaml_config)) { | ||
$GLOBALS['_yml_config'] = $_yaml_config; | ||
unset($_yaml_config); | ||
} | ||
} else { | ||
$GLOBALS['_yml_config'] = Yaml::parseFile(PRE_APP_PATH . 'config.' . $appStatus . '.yml'); | ||
if($cacheYamlConfig){ | ||
$cacheYamlConfigVar = "<?php \n".'$_yaml_config = '.var_export($GLOBALS['_yml_config'], true).";\n"; | ||
@file_put_contents($cacheYamlConfigFile, $cacheYamlConfigVar); | ||
} | ||
} | ||
|
||
|
||
// 加载公共常量定义文件 | ||
include_once APP_PATH."constants.php"; | ||
include_once APP_PATH . "constants.php"; | ||
|
||
// 加载主配置文件 | ||
include_once APP_PATH."config/app.cfg.php"; | ||
include_once APP_PATH . "config/app.cfg.php"; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace main\plugin; | ||
|
||
use Symfony\Contracts\EventDispatcher\Event; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* 插件管理类 | ||
* Class PluginManager | ||
*/ | ||
class PluginManager | ||
{ | ||
/** | ||
* 监听已注册的插件 | ||
* | ||
* @access private | ||
* @var array | ||
*/ | ||
private $_listeners = array(); | ||
|
||
|
||
private $_plugins = array(); | ||
|
||
|
||
/** | ||
* @var EventDispatcher | ||
*/ | ||
public $dispatcher = null; | ||
|
||
/** | ||
* 构造函数 | ||
* | ||
* @access public | ||
* @return void | ||
*/ | ||
public function __construct($ctrlObj, $plugins) | ||
{ | ||
#这里$plugin数组包含我们获取已经由用户激活的插件信息 | ||
#$plugin = array( | ||
# 'name' => '插件名称', | ||
# 'directory'=>'插件安装目录' | ||
#); | ||
$this->dispatcher = new EventDispatcher(); | ||
if ($plugins) { | ||
foreach ($plugins as $plugin) { | ||
$pluginName = $plugin['name']; | ||
$pluginFile = PRE_APP_PATH . 'plugin/' . $plugin['directory'] . '/' . $pluginName . '.php'; | ||
if (file_exists($pluginFile)) { | ||
include_once($pluginFile); | ||
if (class_exists($pluginName)) { | ||
//初始化所有插件 | ||
$this->_plugins[$pluginName] = new $pluginName($ctrlObj, $this); | ||
} | ||
} | ||
} | ||
} | ||
#此处做些日志记录方面的东西 | ||
} | ||
|
||
/** | ||
* 注册需要监听的插件方法(钩子) | ||
* | ||
* @param string $hook | ||
* @param object $reference | ||
* @param string $method | ||
*/ | ||
function register($hook, &$reference, $method) | ||
{ | ||
//获取插件要实现的方法 | ||
$key = get_class($reference) . '->' . $method; | ||
//将插件的引用连同方法push进监听数组中 | ||
$this->_listeners[$hook][$key] = array(&$reference, $method); | ||
#此处做些日志记录方面的东西 | ||
} | ||
|
||
/** | ||
* 触发一个钩子 | ||
* | ||
* @param string $hook 钩子的名称 | ||
* @param mixed $data 钩子的入参 | ||
* @return mixed | ||
*/ | ||
function trigger($hook, $data = null) | ||
{ | ||
$result = ''; | ||
//查看要实现的钩子,是否在监听数组之中 | ||
if (isset($this->_listeners[$hook]) && is_array($this->_listeners[$hook]) && count($this->_listeners[$hook]) > 0) { | ||
// 循环调用开始 | ||
foreach ($this->_listeners[$hook] as $listener) { | ||
// 取出插件对象的引用和方法 | ||
$class =& $listener[0]; | ||
$method = $listener[1]; | ||
if (method_exists($class, $method)) { | ||
// 动态调用插件的方法 | ||
$result .= $class->$method($data); | ||
} | ||
} | ||
} | ||
#此处做些日志记录方面的东西 | ||
return $result; | ||
} | ||
} |
Oops, something went wrong.