format entity parse namespace
This commit is contained in:
@@ -242,12 +242,12 @@ class EntityParseFactory
|
||||
* 根据命名约定查找 Parser 类
|
||||
*
|
||||
* 命名约定:
|
||||
* 1. 类名:{Platform}{Entity}Parser
|
||||
* 2. 命名空间:App\Platform\{Platform}
|
||||
* - 类名:{Entity}
|
||||
* - 命名空间:App\Platform\{Platform}\EntityParse
|
||||
*
|
||||
* 示例:
|
||||
* - Platform: tmall, Entity: order -> App\Platform\Tmall\TmallOrderParser
|
||||
* - Platform: shopee, Entity: product -> App\Platform\Shopee\ShopeeProductParser
|
||||
* - Platform: shopee, Entity: order -> App\Platform\Shopee\EntityParse\Order
|
||||
* - Platform: tmall, Entity: product -> App\Platform\Tmall\EntityParse\Product
|
||||
*
|
||||
* @param string $platformName
|
||||
* @param string $entityType
|
||||
@@ -259,23 +259,11 @@ class EntityParseFactory
|
||||
$platformPascal = Str::of($platformName)->ucfirst()->toString();
|
||||
$entityPascal = Str::of($entityType)->ucfirst()->toString();
|
||||
|
||||
// 尝试的类名列表
|
||||
$possibleClasses = [
|
||||
// App\Platform\Tmall\TmallOrderParser
|
||||
"App\\Platform\\{$platformPascal}\\{$platformPascal}{$entityPascal}Parser",
|
||||
// App\Platform\Tmall\OrderParser
|
||||
"App\\Platform\\{$platformPascal}\\{$entityPascal}Parser",
|
||||
// App\Platform\TmallOrderParser
|
||||
"App\\Platform\\{$platformPascal}{$entityPascal}Parser",
|
||||
];
|
||||
// 标准命名:App\Platform\Shopee\EntityParse\Order
|
||||
$class = "App\\Platform\\{$platformPascal}\\EntityParse\\{$entityPascal}";
|
||||
|
||||
foreach ($possibleClasses as $class) {
|
||||
if (class_exists($class)) {
|
||||
// 验证类是否继承自 EntityParse
|
||||
if (is_subclass_of($class, EntityParse::class)) {
|
||||
return $class;
|
||||
}
|
||||
}
|
||||
if (class_exists($class) && is_subclass_of($class, EntityParse::class)) {
|
||||
return $class;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user