ComposerUpdate

This commit is contained in:
Anyon 2020-08-28 19:49:49 +08:00
parent 652e8ddd03
commit 9704c64d13
11 changed files with 76 additions and 1129 deletions

View File

@ -45,6 +45,7 @@
"@php think vendor:publish" "@php think vendor:publish"
] ]
}, },
"minimum-stability": "stable",
"repositories": { "repositories": {
"packagist": { "packagist": {
"type": "composer", "type": "composer",

1078
composer.lock generated

File diff suppressed because it is too large Load Diff

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252::getLoader(); return ComposerAutoloaderInitb55556af42203bcef68382c66bc39c70::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252 class ComposerAutoloaderInitb55556af42203bcef68382c66bc39c70
{ {
private static $loader; private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInitb55556af42203bcef68382c66bc39c70', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInitb55556af42203bcef68382c66bc39c70', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php'; require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInitb911c14a0826c73d9f097343fd33a252::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInitb55556af42203bcef68382c66bc39c70::getInitializer($loader));
} else { } else {
$map = require __DIR__ . '/autoload_namespaces.php'; $map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) { foreach ($map as $namespace => $path) {
@ -51,19 +51,19 @@ class ComposerAutoloaderInitb911c14a0826c73d9f097343fd33a252
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInitb911c14a0826c73d9f097343fd33a252::$files; $includeFiles = Composer\Autoload\ComposerStaticInitb55556af42203bcef68382c66bc39c70::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireb911c14a0826c73d9f097343fd33a252($fileIdentifier, $file); composerRequireb55556af42203bcef68382c66bc39c70($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequireb911c14a0826c73d9f097343fd33a252($fileIdentifier, $file) function composerRequireb55556af42203bcef68382c66bc39c70($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInitb911c14a0826c73d9f097343fd33a252 class ComposerStaticInitb55556af42203bcef68382c66bc39c70
{ {
public static $files = array ( public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@ -652,10 +652,10 @@ class ComposerStaticInitb911c14a0826c73d9f097343fd33a252
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInitb911c14a0826c73d9f097343fd33a252::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInitb55556af42203bcef68382c66bc39c70::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInitb911c14a0826c73d9f097343fd33a252::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInitb55556af42203bcef68382c66bc39c70::$prefixDirsPsr4;
$loader->fallbackDirsPsr0 = ComposerStaticInitb911c14a0826c73d9f097343fd33a252::$fallbackDirsPsr0; $loader->fallbackDirsPsr0 = ComposerStaticInitb55556af42203bcef68382c66bc39c70::$fallbackDirsPsr0;
$loader->classMap = ComposerStaticInitb911c14a0826c73d9f097343fd33a252::$classMap; $loader->classMap = ComposerStaticInitb55556af42203bcef68382c66bc39c70::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -963,12 +963,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git", "url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "6768de2a30a5d3058c4b6d34a0c99591acc4e476" "reference": "a5c1e18d0e57dd0a83174793f09cca5ba592b773"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/6768de2a30a5d3058c4b6d34a0c99591acc4e476", "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/a5c1e18d0e57dd0a83174793f09cca5ba592b773",
"reference": "6768de2a30a5d3058c4b6d34a0c99591acc4e476", "reference": "a5c1e18d0e57dd0a83174793f09cca5ba592b773",
"shasum": "", "shasum": "",
"mirrors": [ "mirrors": [
{ {
@ -985,7 +985,7 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"topthink/framework": "^6.0" "topthink/framework": "^6.0"
}, },
"time": "2020-08-26T03:59:59+00:00", "time": "2020-08-28T11:32:28+00:00",
"type": "library", "type": "library",
"extra": { "extra": {
"think": { "think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php <?php
// This file is automatically generated at:2020-08-28 16:04:35 // This file is automatically generated at:2020-08-28 19:49:26
declare (strict_types = 1); declare (strict_types = 1);
return array ( return array (
0 => 'think\\admin\\Library', 0 => 'think\\admin\\Library',

View File

@ -177,7 +177,7 @@ abstract class Controller extends \stdClass
public function callback($name, &$one = [], &$two = []) public function callback($name, &$one = [], &$two = [])
{ {
if (is_callable($name)) return call_user_func($name, $this, $one, $two); if (is_callable($name)) return call_user_func($name, $this, $one, $two);
foreach ([$name, "_{$this->app->request->action()}{$name}"] as $method) { foreach (["_{$this->app->request->action()}{$name}", $name] as $method) {
if (method_exists($this, $method) && false === $this->$method($one, $two)) { if (method_exists($this, $method) && false === $this->$method($one, $two)) {
return false; return false;
} }

View File

@ -56,7 +56,7 @@ class ValidateHelper extends Helper
if ($_rule === 'value') $data[$_key] = $message; if ($_rule === 'value') $data[$_key] = $message;
elseif ($_rule === 'default') $data[$_key] = $input[($alias ?: $_key)] ?? $message; elseif ($_rule === 'default') $data[$_key] = $input[($alias ?: $_key)] ?? $message;
} else { } else {
$info[strstr($name, ':', true)] = $message; $info[explode(':', $name)[0]] = $message;
$data[$_key] = $data[$_key] ?? ($input[($alias ?: $_key)] ?? null); $data[$_key] = $data[$_key] ?? ($input[($alias ?: $_key)] ?? null);
$rule[$_key] = isset($rule[$_key]) ? ($rule[$_key] . '|' . $_rule) : $_rule; $rule[$_key] = isset($rule[$_key]) ? ($rule[$_key] . '|' . $_rule) : $_rule;
} }

View File

@ -1,6 +1,5 @@
<?php <?php
// 以下代码来自 topthink/think-multi-app有部分修改以兼容 ThinkAdmin 的需求
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ] // | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
@ -10,6 +9,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// 以下代码来自 topthink/think-multi-app有部分修改以兼容 ThinkAdmin 的需求
// +----------------------------------------------------------------------
namespace think\admin\multiple; namespace think\admin\multiple;
@ -25,9 +26,7 @@ use think\Response;
*/ */
class App class App
{ {
/** /** @var \think\App */
* @var \think\App
*/
protected $app; protected $app;
/** /**
@ -55,14 +54,15 @@ class App
/** /**
* 多应用解析 * 多应用解析
* @access public
* @param Request $request * @param Request $request
* @param Closure $next * @param Closure $next
* @return Response * @return Response
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
if (!$this->parseMultiApp()) return $next($request); if (!$this->parseMultiApp()) {
return $next($request);
}
return $this->app->middleware->pipeline('app')->send($request)->then(function ($request) use ($next) { return $this->app->middleware->pipeline('app')->send($request)->then(function ($request) use ($next) {
return $next($request); return $next($request);
}); });
@ -70,7 +70,6 @@ class App
/** /**
* 获取路由目录 * 获取路由目录
* @access protected
* @return string * @return string
*/ */
protected function getRoutePath(): string protected function getRoutePath(): string
@ -95,8 +94,9 @@ class App
$appName = null; $appName = null;
$bind = $this->app->config->get('app.domain_bind', []); $bind = $this->app->config->get('app.domain_bind', []);
if (!empty($bind)) { if (!empty($bind)) {
$domain = $this->app->request->host(true); // 获取当前子域名
$subDomain = $this->app->request->subDomain(); $subDomain = $this->app->request->subDomain();
$domain = $this->app->request->host(true);
if (isset($bind[$domain])) { if (isset($bind[$domain])) {
$appName = $bind[$domain]; $appName = $bind[$domain];
$this->app->http->setBind(); $this->app->http->setBind();
@ -118,7 +118,8 @@ class App
} }
if (isset($map[$name])) { if (isset($map[$name])) {
if ($map[$name] instanceof Closure) { if ($map[$name] instanceof Closure) {
$appName = call_user_func_array($map[$name], [$this->app]) ?: $name; $result = call_user_func_array($map[$name], [$this->app]);
$appName = $result ?: $name;
} else { } else {
$appName = $map[$name]; $appName = $map[$name];
} }
@ -167,7 +168,7 @@ class App
/** /**
* 设置应用 * 设置应用
* @param string $appName * @param string $appName 应用名称
*/ */
protected function setApp(string $appName): void protected function setApp(string $appName): void
{ {
@ -185,18 +186,27 @@ class App
/** /**
* 加载应用文件 * 加载应用文件
* @param string $appPath * @param string $appPath 应用路径
* @return void * @return void
*/ */
protected function loadApp(string $appPath): void protected function loadApp(string $appPath): void
{ {
if (is_file($appPath . 'common.php')) \Composer\Autoload\includeFile($appPath . 'common.php'); if (is_file($appPath . 'common.php')) {
foreach (glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt()) as $file) { include_once $appPath . 'common.php';
}
$files = glob($appPath . 'config' . DIRECTORY_SEPARATOR . '*' . $this->app->getConfigExt());
foreach ($files as $file) {
$this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME)); $this->app->config->load($file, pathinfo($file, PATHINFO_FILENAME));
} }
if (is_file($appPath . 'event.php')) $this->app->loadEvent(include $appPath . 'event.php'); if (is_file($appPath . 'event.php')) {
if (is_file($appPath . 'provider.php')) $this->app->bind(include $appPath . 'provider.php'); $this->app->loadEvent(include $appPath . 'event.php');
if (is_file($appPath . 'middleware.php')) $this->app->middleware->import(include $appPath . 'middleware.php', 'app'); }
if (is_file($appPath . 'middleware.php')) {
$this->app->middleware->import(include $appPath . 'middleware.php', 'app');
}
if (is_file($appPath . 'provider.php')) {
$this->app->bind(include $appPath . 'provider.php');
}
// 加载应用默认语言包 // 加载应用默认语言包
$this->app->loadLangPack($this->app->lang->defaultLangSet()); $this->app->loadLangPack($this->app->lang->defaultLangSet());
} }

View File

@ -1,6 +1,5 @@
<?php <?php
// 以下代码来自 topthink/think-multi-app有部分修改以兼容 ThinkAdmin 的需求
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ] // | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
@ -10,6 +9,8 @@
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
// 以下代码来自 topthink/think-multi-app有部分修改以兼容 ThinkAdmin 的需求
// +----------------------------------------------------------------------
namespace think\admin\multiple; namespace think\admin\multiple;
@ -42,27 +43,24 @@ class Url extends \think\route\Url
// 解析到控制器 // 解析到控制器
$url = substr($url, 1); $url = substr($url, 1);
} elseif ('' === $url) { } elseif ('' === $url) {
$url = $this->app->http->getName() . '/' . $request->controller() . '/' . $request->action(); $url = $request->controller() . '/' . $request->action();
if (!$this->app->http->isBind()) {
$url = $this->getAppName() . '/' . $url;
}
} else { } else {
// 解析到 应用/控制器/操作 // 解析到 应用/控制器/操作
$controller = $request->controller(); $controller = $request->controller();
$app = $this->app->http->getName();
$path = explode('/', $url); $path = explode('/', $url);
$action = array_pop($path); $action = array_pop($path);
$controller = empty($path) ? $controller : array_pop($path); $controller = empty($path) ? $controller : array_pop($path);
$app = empty($path) ? $app : array_pop($path); $app = empty($path) ? $this->getAppName() : array_pop($path);
$url = Str::snake($controller) . '/' . $action; $url = Str::snake($controller) . '/' . $action;
$bind = $this->app->config->get('app.domain_bind', []); $bind = $this->app->config->get('app.domain_bind', []);
if ($key = array_search($app, $bind)) { if ($key = array_search($this->app->http->getName(), $bind)) {
isset($bind[$_SERVER['SERVER_NAME']]) && $domain = $_SERVER['SERVER_NAME']; isset($bind[$_SERVER['SERVER_NAME']]) && $domain = $_SERVER['SERVER_NAME'];
$domain = is_bool($domain) ? $key : $domain; $domain = is_bool($domain) ? $key : $domain;
} else { } elseif (!$this->app->http->isBind()) {
$map = $this->app->config->get('app.app_map', []); $url = $app . '/' . $url;
if ($key = array_search($app, $map)) {
$url = $key . '/' . $url;
} else {
$url = $app . '/' . $url;
}
} }
} }
return $url; return $url;
@ -106,7 +104,7 @@ class Url extends \think\route\Url
$rule = $this->route->getName($checkName, $checkDomain); $rule = $this->route->getName($checkName, $checkDomain);
if (empty($rule) && isset($info['query'])) { if (empty($rule) && isset($info['query'])) {
$rule = $this->route->getName($url, $checkDomain); $rule = $this->route->getName($url, $checkDomain);
// 解析地址里面参数 合并到 vars // 解析地址里面参数 合并到vars
parse_str($info['query'], $params); parse_str($info['query'], $params);
$vars = array_merge($params, $vars); $vars = array_merge($params, $vars);
unset($info['query']); unset($info['query']);
@ -122,7 +120,8 @@ class Url extends \think\route\Url
$suffix = $match[2]; $suffix = $match[2];
} }
if (!$this->app->http->isBind()) { if (!$this->app->http->isBind()) {
$url = $this->app->http->getName() . '/' . $url; $app = $this->getAppName();
$url = $app . '/' . $url;
} }
} elseif (!empty($rule) && isset($name)) { } elseif (!empty($rule) && isset($name)) {
throw new \InvalidArgumentException('route name not exists:' . $name); throw new \InvalidArgumentException('route name not exists:' . $name);
@ -149,7 +148,7 @@ class Url extends \think\route\Url
$vars = array_merge($params, $vars); $vars = array_merge($params, $vars);
} }
} }
// 还原 URL 分隔符 // 还原URL分隔符
$depr = $this->route->config('pathinfo_depr'); $depr = $this->route->config('pathinfo_depr');
$url = str_replace('/', $depr, $url); $url = str_replace('/', $depr, $url);
$file = $request->baseFile(); $file = $request->baseFile();
@ -188,4 +187,19 @@ class Url extends \think\route\Url
// URL组装 // URL组装
return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/'); return $domain . rtrim($this->root, '/') . '/' . ltrim($url, '/');
} }
/**
* 获取URL的应用名
* @access protected
* @return string
*/
protected function getAppName()
{
$app = $this->app->http->getName();
$map = $this->app->config->get('app.app_map', []);
if ($key = array_search($app, $map)) {
$app = $key;
}
return $app;
}
} }