mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Allow nullable asset packages
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user