Allow nullable asset packages

This commit is contained in:
Dan Harrin
2025-07-01 10:27:19 +01:00
parent fb40aef48d
commit 4d0c87af23
+11 -5
View File
@@ -14,7 +14,7 @@ abstract class Asset
protected bool $isLoadedOnRequest = false;
protected string $package;
protected ?string $package = null;
final public function __construct(string $id, ?string $path = null)
{
@@ -39,14 +39,14 @@ abstract class Asset
return $this->id;
}
public function package(string $package): static
public function package(?string $package): static
{
$this->package = $package;
return $this;
}
public function getPackage(): string
public function getPackage(): ?string
{
return $this->package;
}
@@ -63,15 +63,21 @@ abstract class Asset
public function getVersion(): string
{
$package = $this->getPackage();
if (blank($package)) {
return InstalledVersions::getVersion('filament/support');
}
if (
($this->getPackage() === 'app') &&
($package === 'app') &&
filled($appVersion = FilamentAsset::getAppVersion())
) {
return $appVersion;
}
try {
return InstalledVersions::getVersion($this->getPackage());
return InstalledVersions::getVersion($package);
} catch (Throwable $exception) {
return InstalledVersions::getVersion('filament/support');
}