Store the customized Shopro mall so it can be kept on the remote.

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
wikiboss
2026-09-22 13:55:12 +08:00
当前提交 b87880e247
共有 2547 个文件被更改,包括 423496 次插入 和 0 次删除

查看文件

@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace Yansongda\Artful\Service;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\ConfigInterface;
use Yansongda\Artful\Contract\ServiceProviderInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Supports\Config;
class ConfigServiceProvider implements ServiceProviderInterface
{
private array $config = [
'logger' => [
'enable' => false,
'file' => null,
'identify' => 'yansongda.artful',
'level' => 'debug',
'type' => 'daily',
'max_files' => 30,
],
'http' => [
'timeout' => 5.0,
'connect_timeout' => 3.0,
'headers' => [
'User-Agent' => 'yansongda/artful-v1',
],
],
];
/**
* @throws ContainerException
*/
public function register(mixed $data = null): void
{
$config = new Config(array_replace_recursive($this->config, $data ?? []));
Artful::set(ConfigInterface::class, $config);
}
}

查看文件

@@ -0,0 +1,108 @@
<?php
declare(strict_types=1);
namespace Yansongda\Artful\Service;
use Closure;
use Hyperf\Context\ApplicationContext as HyperfContainer;
use Hyperf\Pimple\ContainerFactory as DefaultContainer;
use Illuminate\Container\Container as LaravelContainer;
use Psr\Container\ContainerInterface;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\ServiceProviderInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\ContainerNotFoundException;
use Yansongda\Artful\Exception\Exception;
/**
* @codeCoverageIgnore
*/
class ContainerServiceProvider implements ServiceProviderInterface
{
private array $detectApplication = [
'laravel' => LaravelContainer::class,
'hyperf' => HyperfContainer::class,
];
/**
* @throws ContainerException
*/
public function register(mixed $data = null): void
{
if ($data instanceof ContainerInterface || $data instanceof Closure) {
Artful::setContainer($data);
return;
}
if (Artful::hasContainer()) {
return;
}
foreach ($this->detectApplication as $framework => $application) {
$method = $framework.'Application';
if (class_exists($application) && method_exists($this, $method) && $this->{$method}()) {
return;
}
}
$this->defaultApplication();
}
/**
* @throws ContainerException
* @throws ContainerNotFoundException
*/
protected function laravelApplication(): bool
{
Artful::setContainer(static fn () => LaravelContainer::getInstance());
Artful::set(\Yansongda\Artful\Contract\ContainerInterface::class, LaravelContainer::getInstance());
if (!Artful::has(ContainerInterface::class)) {
Artful::set(ContainerInterface::class, LaravelContainer::getInstance());
}
return true;
}
/**
* @throws ContainerException
* @throws ContainerNotFoundException
*/
protected function hyperfApplication(): bool
{
if (!HyperfContainer::hasContainer()) {
return false;
}
Artful::setContainer(static fn () => HyperfContainer::getContainer());
Artful::set(\Yansongda\Artful\Contract\ContainerInterface::class, HyperfContainer::getContainer());
if (!Artful::has(ContainerInterface::class)) {
Artful::set(ContainerInterface::class, HyperfContainer::getContainer());
}
return true;
}
/**
* @throws ContainerException
* @throws ContainerNotFoundException
*/
protected function defaultApplication(): void
{
if (!class_exists(DefaultContainer::class)) {
throw new ContainerNotFoundException('容器未找到: Init failed! Maybe you should install `hyperf/pimple` first', Exception::CONTAINER_NOT_FOUND);
}
$container = (new DefaultContainer())();
Artful::setContainer($container);
Artful::set(\Yansongda\Artful\Contract\ContainerInterface::class, $container);
}
}

查看文件

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Yansongda\Artful\Service;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\EventDispatcherInterface;
use Yansongda\Artful\Contract\ServiceProviderInterface;
use Yansongda\Artful\Exception\ContainerException;
class EventServiceProvider implements ServiceProviderInterface
{
/**
* @throws ContainerException
*/
public function register(mixed $data = null): void
{
if (class_exists(EventDispatcher::class)) {
Artful::set(EventDispatcherInterface::class, new EventDispatcher());
}
}
}

查看文件

@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace Yansongda\Artful\Service;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\HttpClientFactoryInterface;
use Yansongda\Artful\Contract\ServiceProviderInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\HttpClientFactory;
class HttpServiceProvider implements ServiceProviderInterface
{
/**
* @throws ContainerException
*/
public function register(mixed $data = null): void
{
$container = Artful::getContainer();
Artful::set(HttpClientFactoryInterface::class, new HttpClientFactory($container));
}
}

查看文件

@@ -0,0 +1,71 @@
<?php
declare(strict_types=1);
namespace Yansongda\Artful\Service;
use Monolog\Formatter\LineFormatter;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Handler\RotatingFileHandler;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\ConfigInterface;
use Yansongda\Artful\Contract\LoggerInterface;
use Yansongda\Artful\Contract\ServiceProviderInterface;
use Yansongda\Artful\Exception\ContainerException;
use Yansongda\Artful\Exception\ServiceNotFoundException;
class LoggerServiceProvider implements ServiceProviderInterface
{
protected array $config = [
'enable' => false,
'file' => null,
'identify' => 'yansongda.artful',
'level' => 'DEBUG',
'type' => 'daily',
'max_files' => 30,
'formatter' => "%datetime% > %channel%.%level_name% > %message% %context% %extra%\n\n",
];
/**
* @throws ContainerException
* @throws ServiceNotFoundException
*/
public function register(mixed $data = null): void
{
/* @var ConfigInterface $config */
$config = Artful::get(ConfigInterface::class);
$this->config = array_merge($this->config, $config->get('logger', []));
if (class_exists(Logger::class) && (true === ($this->config['enable'] ?? false))) {
$logger = new Logger($this->config['identify']);
$logger->pushHandler($this->getDefaultHandler()
->setFormatter($this->getDefaultFormatter()));
Artful::set(LoggerInterface::class, $logger);
}
}
protected function getDefaultFormatter(): LineFormatter
{
return new LineFormatter(
$this->config['formatter'],
null,
false,
true
);
}
protected function getDefaultHandler(): AbstractProcessingHandler
{
$file = $this->config['file'] ?? (sys_get_temp_dir().'/logs/'.$this->config['identify'].'.log');
return match ($this->config['type']) {
'single' => new StreamHandler($file, $this->config['level']),
default => new RotatingFileHandler($file, $this->config['max_files'], $this->config['level']),
};
}
}