Skip to content

Commit

Permalink
Fixed finding template generator stubs for user add-ons
Browse files Browse the repository at this point in the history
  • Loading branch information
bryannielsen committed Dec 10, 2024
1 parent a3f9278 commit fa59797
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Dependency/StubFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use ExpressionEngine\Core\Provider;
use ExpressionEngine\Service\View\StubFactory as Factory;
use Illuminate\Support\Str;

class StubFactory extends Factory
{
Expand All @@ -25,9 +26,11 @@ public function getGeneratorStubPaths(Provider $provider, string $generatorFolde
$paths = parent::getGeneratorStubPaths($provider, $generatorFolder, $theme);

$basePath = realpath(__DIR__.'/../../resources/stubs');
// The path at index 0 is the user override path which should always be the highest priority
// If the path at index 1 is a user addon it should also take priority over our overrides
$offset = Str::contains($paths[1], 'system/user/addons') ? 2 : 1;

// The path at index 0 is the user override path which we still want to be the highest priority
array_splice($paths, 1, 0, [
array_splice($paths, $offset, 0, [
$basePath.'/fieldtypes/'.$provider->getPrefix().($generatorFolder ? "/$generatorFolder" : ''),
$basePath.'/fieldtypes',
$basePath.'/templates/'.$provider->getPrefix().($generatorFolder ? "/$generatorFolder" : ''),
Expand Down

0 comments on commit fa59797

Please sign in to comment.