This commit is contained in:
yansongda 2021-06-06 17:53:47 +08:00
parent a976e0870c
commit a434f127ac
4 changed files with 21 additions and 7 deletions

View File

@ -10,11 +10,14 @@ use Yansongda\Pay\Rocket;
use Yansongda\Supports\Config;
use Yansongda\Supports\Str;
if (!function_exists('should_http_request')) {
function should_http_request(Rocket $rocket): bool
if (!function_exists('should_do_http_request')) {
function should_do_http_request(Rocket $rocket): bool
{
return NoHttpRequestParser::class !== $rocket->getDirection() &&
!in_array(NoHttpRequestParser::class, class_parents($rocket->getDirection()));
$direction = $rocket->getDirection();
return is_null($direction) ||
(NoHttpRequestParser::class !== $direction &&
!in_array(NoHttpRequestParser::class, class_parents($direction)));
}
}

View File

@ -120,6 +120,8 @@ class Pay
* @author yansongda <me@yansongda.cn>
*
* @param mixed $value
*
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function set(string $name, $value): void
{
@ -148,6 +150,9 @@ class Pay
}
}
/**
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function has(string $service): bool
{
return Pay::getContainer()->has($service);
@ -157,10 +162,16 @@ class Pay
* getContainer.
*
* @author yansongda <me@yansongda.cn>
*
* @throws \Yansongda\Pay\Exception\ContainerException
*/
public static function getContainer(): Container
{
return self::$container;
if (self::$container) {
return self::$container;
}
throw new ContainerException('You should init/config PAY first', ContainerException::CONTAINER_NOT_FOUND);
}
/**

View File

@ -24,7 +24,7 @@ class LaunchPlugin implements PluginInterface
/* @var Rocket $rocket */
$rocket = $next($rocket);
if (!should_http_request($rocket)) {
if (!should_do_http_request($rocket)) {
return $rocket;
}

View File

@ -51,7 +51,7 @@ abstract class AbstractProvider
*/
public function ignite(Rocket $rocket): Rocket
{
if (!should_http_request($rocket)) {
if (!should_do_http_request($rocket)) {
return $rocket;
}