Skip to content

Commit d9d6b20

Browse files
[5.x] Prevent autoloading addon files causing exception when called early (#10875)
Co-authored-by: Jason Varga <jason@pixelfear.com>
1 parent c3c63e2 commit d9d6b20

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Providers/AddonServiceProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,15 @@ protected function bootFieldsets()
728728

729729
protected function autoloadFilesFromFolder($folder, $requiredClass)
730730
{
731-
$addon = $this->getAddon();
731+
try {
732+
$addon = $this->getAddon();
733+
} catch (NotBootedException $e) {
734+
// This would be thrown if a developer has tried to call a method
735+
// that triggers autoloading before Statamic has booted. Perhaps
736+
// they have placed it in the boot method instead of bootAddon.
737+
return [];
738+
}
739+
732740
$path = $addon->directory().$addon->autoload().'/'.$folder;
733741

734742
if (! $this->app['files']->exists($path)) {

0 commit comments

Comments
 (0)