Skip to content

Commit 9291560

Browse files
authored
Use autoload for loading legacy craft so it only loads when needed (#18093)
1 parent d71164c commit 9291560

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Cms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
public static function config(): GeneralConfig
2424
{
25-
return app(GeneralConfig::class);
25+
return app(GeneralConfig::class) ?? GeneralConfig::create();
2626
}
2727

2828
public static function systemName(): string

yii2-adapter/src/Yii2ServiceProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,13 @@ public function boot(): void
353353
));
354354

355355
/**
356-
* Load Craft
356+
* Load Craft when necessary
357357
*/
358-
app('Craft');
358+
spl_autoload_register(function($class) {
359+
if ($class === 'Craft') {
360+
app('Craft');
361+
}
362+
});
359363

360364
$this->ensureNewMigrationTable();
361365

0 commit comments

Comments
 (0)