Skip to content

Commit f838777

Browse files
[4.x] Adds closure evaluation to TimezoneManager (#18544)
* Adds closure evaluation to the timezone manager * Update TimezoneManager.php * Update FilamentTimezone.php --------- Co-authored-by: Dan Harrin <[email protected]>
1 parent 6a20fda commit f838777

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/support/src/Facades/FilamentTimezone.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Filament\Support\Facades;
44

5+
use Closure;
56
use Filament\Support\TimezoneManager;
67
use Illuminate\Support\Facades\Facade;
78

89
/**
9-
* @method static void set(?string $timezone)
10+
* @method static void set(string | Closure | null $timezone)
1011
* @method static string get()
1112
*
1213
* @see TimezoneManager

packages/support/src/TimezoneManager.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22

33
namespace Filament\Support;
44

5+
use Closure;
6+
use Filament\Support\Concerns\EvaluatesClosures;
7+
58
class TimezoneManager
69
{
7-
protected ?string $timezone = null;
10+
use EvaluatesClosures;
11+
12+
protected string | Closure | null $timezone = null;
813

9-
public function set(?string $timezone): void
14+
public function set(string | Closure | null $timezone = null): void
1015
{
1116
$this->timezone = $timezone;
1217
}
1318

1419
public function get(): string
1520
{
16-
return $this->timezone ?? config('app.timezone');
21+
return $this->evaluate($this->timezone) ?? config('app.timezone');
1722
}
1823
}

0 commit comments

Comments
 (0)