Skip to content

Commit

Permalink
Locator location uses Composer package as name, fallback to slug of name
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Feb 13, 2024
1 parent 7dc4fee commit bc11596
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/src/ServicesProvider/LocatorService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@

namespace UserFrosting\Sprinkle\Core\ServicesProvider;

use Illuminate\Support\Str;
use Psr\EventDispatcher\EventDispatcherInterface;
use UserFrosting\ServicesProvider\ServicesProviderInterface;
use UserFrosting\Sprinkle\Core\Event\ResourceLocatorInitiatedEvent;
use UserFrosting\Sprinkle\Core\Sprinkle\Recipe\ComposerRecipe;
use UserFrosting\Sprinkle\SprinkleManager;
use UserFrosting\UniformResourceLocator\ResourceLocation;
use UserFrosting\UniformResourceLocator\ResourceLocator;
Expand All @@ -35,7 +37,10 @@ public function register(): array

// Register all sprinkles locations
foreach ($sprinkleManager->getSprinkles() as $sprinkle) {
$location = new ResourceLocation($sprinkle->getName(), $sprinkle->getPath());
$slug = ($sprinkle instanceof ComposerRecipe)
? $sprinkle->getComposerPackage()
: Str::slug($sprinkle->getName());
$location = new ResourceLocation($slug, $sprinkle->getPath());
$locator->addLocation($location);
}

Expand Down

0 comments on commit bc11596

Please sign in to comment.