Use sprinkle manager

This commit is contained in:
2023-05-31 15:59:54 +01:00
parent ea722e2023
commit 2bed04cd18

View File

@@ -179,15 +179,19 @@ class Scheduler
*/ */
protected function getTaskDetails(ResourceInstance $file) protected function getTaskDetails(ResourceInstance $file)
{ {
/** @var \UserFrosting\System\Sprinkle\SprinkleManager */
$sprinkleManager = $this->ci->sprinkleManager;
// Format the sprinkle name for the namespace // Format the sprinkle name for the namespace
$sprinkleName = $file->getLocation()->getName(); $sprinkleName = $file->getLocation()->getName();
$sprinkleName = Str::studly($sprinkleName); $sprinkleNS = $sprinkleManager->getSprinkleClassNamespace($sprinkleName);
// Getting base path, name and class name // Getting base path, name and class name
$basePath = str_replace($file->getBasename(), '', $file->getBasePath()); $basePath = str_replace($file->getBasename(), '', $file->getBasePath());
$name = $basePath . $file->getFilename(); $name = $basePath . $file->getFilename();
$className = str_replace('/', '\\', $basePath) . $file->getFilename(); $className = str_replace('/', '\\', $basePath) . $file->getFilename();
$classPath = "\\UserFrosting\\Sprinkle\\$sprinkleName\\Scheduler\\Tasks\\$className"; $classPath = "\\$sprinkleNS\\Scheduler\\Tasks\\$className";
if (!class_exists($classPath)) { if (!class_exists($classPath)) {
throw new \Exception("Task class `$className` not found. Make sure the class has the correct namespace."); throw new \Exception("Task class `$className` not found. Make sure the class has the correct namespace.");