Skip to content

Commit

Permalink
composer path finder and event backwardscompatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelfolaron committed Nov 16, 2024
1 parent 8b97857 commit 2674245
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/Core/Events/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,13 @@ public static function add_event_listener(
): void {

//Some backwards compatibility rules
$eventName = str_replace('leantime.core.template.tpl', 'leantime.*', $eventName);
if(str_starts_with($eventName, "leantime.core.template.tpl")) {
$eventParts = explode(".", $eventName);

$count = count($eventParts);

$eventName = "leantime.*.".($eventParts[$count-2] ?? '').".".($eventParts[$count-1] ?? '');
}

if (! array_key_exists($eventName, self::$eventRegistry)) {
self::$eventRegistry[$eventName] = [];
Expand Down
4 changes: 3 additions & 1 deletion app/Core/Providers/Views.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ private function discoverComposerPaths()
$enabledPlugins = $this->app->make(\Leantime\Domain\Plugins\Services\Plugins::class)->getEnabledPlugins();
$pluginComposerClasses = collect($enabledPlugins)
->map(function ($plugin) {

if ($plugin->format === 'phar') {
$pharPath = APP_ROOT.'/app/Plugins/'.$plugin->foldername.'/'.$plugin->foldername.'.phar';

Expand All @@ -281,7 +282,8 @@ private function discoverComposerPaths()
}
}

return glob(APP_ROOT.'app/Views/Composers/*.php') ?: [];
//If not a phar, we can just use glob
return glob(APP_ROOT.'/app/Plugins/'.$plugin->foldername.'/Composers/*.php') ?: [];
})
->flatten();

Expand Down

0 comments on commit 2674245

Please sign in to comment.