actionBegin(); } // 插件方法加载开始 public function addonActionBegin() { $this->actionBegin(); } // 模块控制器方法加载开始 public function actionBegin() { //添加命名空间 if (!class_exists('\Yansongda\Pay\Pay')) { //SDK版本 $version = Service::getSdkVersion(); $libraryDir = ADDON_PATH . 'epay' . DS . 'library' . DS; Loader::addNamespace('Yansongda\Pay', $libraryDir . $version . DS . 'Yansongda' . DS . 'Pay' . DS); $checkArr = [ '\Hyperf\Context\Context' => 'context', '\Hyperf\Contract\Castable' => 'contract', '\Hyperf\Engine\Constant' => 'engine', '\Hyperf\Macroable\Macroable' => 'macroable', '\Hyperf\Pimple\Container' => 'pimple', '\Hyperf\Utils\Arr' => 'utils', ]; foreach ($checkArr as $index => $item) { if (!class_exists($index)) { Loader::addNamespace(substr($index, 1, strrpos($index, '\\') - 1), $libraryDir . 'hyperf' . DS . $item . DS . 'src' . DS); } } if (!class_exists('\Yansongda\Supports\Logger')) { Loader::addNamespace('Yansongda\Supports', $libraryDir . $version . DS . 'Yansongda' . DS . 'Supports' . DS); } // V3需载入辅助函数 if ($version == Service::SDK_VERSION_V3) { require_once $libraryDir . $version . DS . 'Yansongda' . DS . 'Pay' . DS . 'Functions.php'; } } } }