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