Browse Source

优化部分

master
wuliangbo 10 months ago
parent
commit
8e7d981996
11 changed files with 30 additions and 49 deletions
  1. +2
    -2
      src/Kernel/AccessToken.php
  2. +1
    -1
      src/Kernel/Providers/ConfigServiceProvider.php
  3. +1
    -1
      src/Kernel/Providers/EventDispatcherServiceProvider.php
  4. +1
    -1
      src/Kernel/Providers/ExtensionServiceProvider.php
  5. +1
    -1
      src/Kernel/Providers/HttpClientServiceProvider.php
  6. +3
    -36
      src/Kernel/Providers/LogServiceProvider.php
  7. +1
    -1
      src/Kernel/Providers/RequestServiceProvider.php
  8. +2
    -2
      src/Kernel/ServiceContainer.php
  9. +1
    -1
      src/Kernel/Traits/Observable.php
  10. +1
    -1
      src/OfficialAccount/Store/Client.php
  11. +16
    -2
      src/OpenPlatform/Authorizer/MiniProgram/Tester/Client.php

+ 2
- 2
src/Kernel/AccessToken.php View File

@@ -105,8 +105,8 @@ abstract class AccessToken implements AccessTokenInterface
$cacheKey = $this->getCacheKey();
$cache = $this->getCache();

if (!$refresh && $cache->has($cacheKey)) {
return $cache->get($cacheKey);
if (!$refresh && $cache->has($cacheKey) && $result = $cache->get($cacheKey)) {
return $result;
}

/** @var array $token */


+ 1
- 1
src/Kernel/Providers/ConfigServiceProvider.php View File

@@ -32,7 +32,7 @@ class ConfigServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['config'] = function ($app) {
!isset($pimple['config']) && $pimple['config'] = function ($app) {
return new Config($app->getConfig());
};
}


+ 1
- 1
src/Kernel/Providers/EventDispatcherServiceProvider.php View File

@@ -32,7 +32,7 @@ class EventDispatcherServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['events'] = function ($app) {
!isset($pimple['events']) && $pimple['events'] = function ($app) {
$dispatcher = new EventDispatcher();

foreach ($app->config->get('events.listen', []) as $event => $listeners) {


+ 1
- 1
src/Kernel/Providers/ExtensionServiceProvider.php View File

@@ -32,7 +32,7 @@ class ExtensionServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['extension'] = function ($app) {
!isset($pimple['extension']) && $pimple['extension'] = function ($app) {
return new Extension($app);
};
}


+ 1
- 1
src/Kernel/Providers/HttpClientServiceProvider.php View File

@@ -32,7 +32,7 @@ class HttpClientServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['http_client'] = function ($app) {
!isset($pimple['http_client']) && $pimple['http_client'] = function ($app) {
return new Client($app['config']->get('http', []));
};
}


+ 3
- 36
src/Kernel/Providers/LogServiceProvider.php View File

@@ -32,8 +32,8 @@ class LogServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['logger'] = $pimple['log'] = function ($app) {
$config = $this->formatLogConfig($app);
!isset($pimple['log']) && $pimple['log'] = function ($app) {
$config = $app['config']->get('log');

if (!empty($config)) {
$app->rebind('config', $app['config']->merge($config));
@@ -41,39 +41,6 @@ class LogServiceProvider implements ServiceProviderInterface

return new LogManager($app);
};
}

public function formatLogConfig($app)
{
if (!empty($app['config']->get('log.channels'))) {
return $app['config']->get('log');
}

if (empty($app['config']->get('log'))) {
return [
'log' => [
'default' => 'errorlog',
'channels' => [
'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
],
],
],
];
}

return [
'log' => [
'default' => 'single',
'channels' => [
'single' => [
'driver' => 'single',
'path' => $app['config']->get('log.file') ?: \sys_get_temp_dir().'/logs/easywechat.log',
'level' => $app['config']->get('log.level', 'debug'),
],
],
],
];
!isset($pimple['logger']) && $pimple['logger'] = $pimple['log'];
}
}

+ 1
- 1
src/Kernel/Providers/RequestServiceProvider.php View File

@@ -32,7 +32,7 @@ class RequestServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['request'] = function () {
!isset($pimple['request']) && $pimple['request'] = function () {
return Request::createFromGlobals();
};
}


+ 2
- 2
src/Kernel/ServiceContainer.php View File

@@ -64,11 +64,11 @@ class ServiceContainer extends Container
*/
public function __construct(array $config = [], array $prepends = [], string $id = null)
{
$this->registerProviders($this->getProviders());
$this->userConfig = $config;

parent::__construct($prepends);

$this->userConfig = $config;
$this->registerProviders($this->getProviders());

$this->id = $id;



+ 1
- 1
src/Kernel/Traits/Observable.php View File

@@ -157,7 +157,7 @@ trait Observable
case true === $response:
continue 2;
case false === $response:
break 2;
break 3;
case !empty($response) && !($result instanceof FinallyResult):
$result = $response;
}


+ 1
- 1
src/OfficialAccount/Store/Client.php View File

@@ -75,7 +75,7 @@ class Client extends BaseClient
*/
public function getStatus()
{
return $this->httpPostJson('wxa/get_merchant_audit_info');
return $this->httpGet('wxa/get_merchant_audit_info');
}

/**


+ 16
- 2
src/OpenPlatform/Authorizer/MiniProgram/Tester/Client.php View File

@@ -41,19 +41,33 @@ class Client extends BaseClient
* 解绑小程序体验者.
*
* @param string $wechatId
* @param string $userStr
*
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
*
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function unbind(string $wechatId)
public function unbind(string $wechatId = null, string $userStr = null)
{
return $this->httpPostJson('wxa/unbind_tester', [
'wechatid' => $wechatId,
($userStr ? 'userstr' : 'wechatid') => $userStr ?? $wechatId,
]);
}

/**
* @param string $userStr
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
*/
public function unbindWithUserStr(string $userStr)
{
return $this->httpPostJson('wxa/unbind_tester', [
'userstr' => $userStr,
]);
}


/**
* 获取体验者列表.
*


Loading…
Cancel
Save