|
|
<?php
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
// +----------------------------------------------------------------------
|
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
namespace crmeb\services\copyproduct;
|
|
|
|
|
|
use crmeb\basic\BaseManager;
|
|
|
use crmeb\services\AccessTokenServeService;
|
|
|
use think\facade\Config;
|
|
|
use think\Container;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Class Product
|
|
|
* @package crmeb\services\copyproduct
|
|
|
* @mixin \crmeb\services\copyproduct\storage\Copy
|
|
|
* @mixin \crmeb\services\copyproduct\storage\Copy99api
|
|
|
*/
|
|
|
class CopyProduct extends BaseManager
|
|
|
{
|
|
|
/**
|
|
|
* 空间名
|
|
|
* @var string
|
|
|
*/
|
|
|
protected $namespace = '\\crmeb\\services\\copyproduct\\storage\\';
|
|
|
|
|
|
/**
|
|
|
* 默认驱动
|
|
|
* @return mixed
|
|
|
*/
|
|
|
protected function getDefaultDriver()
|
|
|
{
|
|
|
return Config::get('product.default', 'copy');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取类的实例
|
|
|
* @param $class
|
|
|
* @return mixed|void
|
|
|
*/
|
|
|
protected function invokeClass($class)
|
|
|
{
|
|
|
if (!class_exists($class)) {
|
|
|
throw new \RuntimeException('class not exists: ' . $class);
|
|
|
}
|
|
|
$this->getConfigFile();
|
|
|
|
|
|
if (!$this->config) {
|
|
|
$this->config = Config::get($this->configFile . '.stores.' . $this->name, []);
|
|
|
}
|
|
|
$handleAccessToken = new AccessTokenServeService($this->config['account'] ?? '', $this->config['secret'] ?? '');
|
|
|
$handle = Container::getInstance()->invokeClass($class, [$this->name, $handleAccessToken, $this->configFile]);
|
|
|
$this->config = [];
|
|
|
return $handle;
|
|
|
}
|
|
|
|
|
|
}
|