Store the customized Shopro mall so it can be kept on the remote.
Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Artful\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\InvalidParamsException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
use function Yansongda\Artful\filter_params;
|
||||
use function Yansongda\Artful\get_packer;
|
||||
|
||||
class AddPayloadBodyPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidParamsException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[AddPayloadBodyPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$packer = get_packer($rocket->getPacker());
|
||||
|
||||
$rocket->mergePayload(['_body' => $packer->pack(filter_params($rocket->getPayload()))]);
|
||||
|
||||
Logger::info('[AddPayloadBodyPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Artful\Plugin;
|
||||
|
||||
use Closure;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
use function Yansongda\Artful\get_radar_body;
|
||||
use function Yansongda\Artful\get_radar_headers;
|
||||
use function Yansongda\Artful\get_radar_method;
|
||||
use function Yansongda\Artful\get_radar_url;
|
||||
|
||||
class AddRadarPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[AddRadarPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
$rocket->setRadar(new Request(
|
||||
get_radar_method($payload) ?? 'POST',
|
||||
get_radar_url($payload),
|
||||
get_radar_headers($payload) ?? $this->getHeaders(),
|
||||
get_radar_body($payload),
|
||||
));
|
||||
|
||||
Logger::info('[AddRadarPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
|
||||
protected function getHeaders(): array
|
||||
{
|
||||
return [
|
||||
'User-Agent' => 'yansongda/artful-v1',
|
||||
'Content-Type' => 'application/json;charset=utf-8',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Artful\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Exception\Exception;
|
||||
use Yansongda\Artful\Exception\InvalidParamsException;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
use function Yansongda\Artful\get_direction;
|
||||
use function Yansongda\Artful\get_packer;
|
||||
|
||||
class ParserPlugin implements PluginInterface
|
||||
{
|
||||
/**
|
||||
* @throws InvalidParamsException
|
||||
*/
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
/* @var Rocket $rocket */
|
||||
$rocket = $next($rocket);
|
||||
|
||||
Logger::debug('[ParserPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$response = $rocket->getDestination();
|
||||
$direction = get_direction($rocket->getDirection());
|
||||
$packer = get_packer($rocket->getPacker());
|
||||
$payload = $rocket->getPayload();
|
||||
|
||||
if (!is_null($response) && !($response instanceof ResponseInterface)) {
|
||||
throw new InvalidParamsException(Exception::PARAMS_PARSER_DIRECTION_INVALID, '参数异常: 解析插件中 `Rocket` 的 `destination` 只能是 `null` 或者 `ResponseInterface`');
|
||||
}
|
||||
|
||||
$rocket->setDestination($direction->guide($packer, $response, $payload?->all() ?? []));
|
||||
|
||||
Logger::debug('[ParserPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $rocket;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Yansongda\Artful\Plugin;
|
||||
|
||||
use Closure;
|
||||
use Yansongda\Artful\Contract\PluginInterface;
|
||||
use Yansongda\Artful\Logger;
|
||||
use Yansongda\Artful\Rocket;
|
||||
|
||||
class StartPlugin implements PluginInterface
|
||||
{
|
||||
public function assembly(Rocket $rocket, Closure $next): Rocket
|
||||
{
|
||||
Logger::debug('[StartPlugin] 插件开始装载', ['rocket' => $rocket]);
|
||||
|
||||
$rocket->mergePayload($rocket->getParams());
|
||||
|
||||
Logger::info('[StartPlugin] 插件装载完毕', ['rocket' => $rocket]);
|
||||
|
||||
return $next($rocket);
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户