mirror of
				https://gitee.com/zoujingli/ThinkAdmin.git
				synced 2025-10-27 02:12:08 +08:00 
			
		
		
		
	Update WechatService.php
This commit is contained in:
		
							parent
							
								
									892d6e930c
								
							
						
					
					
						commit
						b19f9bf601
					
				| @ -93,20 +93,13 @@ class WechatService extends Service | |||||||
|      */ |      */ | ||||||
|     public static function __callStatic($name, $arguments) |     public static function __callStatic($name, $arguments) | ||||||
|     { |     { | ||||||
|         if (sysconf('wechat.type') === 'api') { |         list($type, $class, $classname) = self::paraseName($name); | ||||||
|             list($type, $class) = ['-', '-']; |         if ("{$type}{$class}" !== $name) { | ||||||
|             foreach (['WeChat', 'WeMini', 'WeOpen', 'WePay', 'ThinkAdmin'] as $type) { |             throw new \think\Exception("抱歉,需要实例的 {$name} 不在符合规则!"); | ||||||
|                 if (strpos($name, $type) === 0) { |         } | ||||||
|                     list(, $class) = explode($type, $name); |         if (sysconf('wechat.type') === 'api' || $type === 'WePay') { | ||||||
|                     break; |  | ||||||
|                 } |  | ||||||
|             } |  | ||||||
|             if ("{$type}{$class}" !== $name) { |  | ||||||
|                 throw new \think\Exception("class {$name} not defined."); |  | ||||||
|             } |  | ||||||
|             $classname = "\\{$type}\\{$class}"; |  | ||||||
|             if ($type === 'ThinkAdmin') { |             if ($type === 'ThinkAdmin') { | ||||||
|                 throw new \think\Exception("Interface mode cannot instance {$classname}"); |                 throw new \think\Exception("抱歉,接口模式不能实例 {$classname} 对象!"); | ||||||
|             } |             } | ||||||
|             return new $classname(self::instance()->getConfig()); |             return new $classname(self::instance()->getConfig()); | ||||||
|         } else { |         } else { | ||||||
| @ -133,6 +126,22 @@ class WechatService extends Service | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * 解析调用对象名称 | ||||||
|  |      * @param string $name | ||||||
|  |      * @return array | ||||||
|  |      */ | ||||||
|  |     private static function paraseName($name) | ||||||
|  |     { | ||||||
|  |         foreach (['WeChat', 'WeMini', 'WeOpen', 'WePay', 'ThinkAdmin'] as $type) { | ||||||
|  |             if (strpos($name, $type) === 0) { | ||||||
|  |                 list(, $class) = explode($type, $name); | ||||||
|  |                 return [$type, $class, "\\{$type}\\{$class}"]; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return ['-', '-', $name]; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     /** |     /** | ||||||
|      * 获取当前微信APPID |      * 获取当前微信APPID | ||||||
|      * @return bool|string |      * @return bool|string | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user