Skip to content

Commit 6a91981

Browse files
feat(event): pass Theme object instead of just the name
fix #73
1 parent 9fef2f6 commit 6a91981

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

src/Events/ThemeDisabled.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Hexadog\ThemesManager\Events;
66

7+
use Hexadog\ThemesManager\Theme;
8+
79
class ThemeDisabled
810
{
9-
public array|string $theme;
11+
public Theme $theme;
1012

11-
public function __construct($theme)
13+
public function __construct(Theme $theme)
1214
{
1315
$this->theme = $theme;
1416
}

src/Events/ThemeDisabling.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Hexadog\ThemesManager\Events;
66

7+
use Hexadog\ThemesManager\Theme;
8+
79
class ThemeDisabling
810
{
9-
public array|string $theme;
11+
public Theme $theme;
1012

11-
public function __construct($theme)
13+
public function __construct(Theme $theme)
1214
{
1315
$this->theme = $theme;
1416
}

src/Events/ThemeEnabled.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Hexadog\ThemesManager\Events;
66

7+
use Hexadog\ThemesManager\Theme;
8+
79
class ThemeEnabled
810
{
9-
public array|string $theme;
11+
public Theme $theme;
1012

11-
public function __construct($theme)
13+
public function __construct(Theme $theme)
1214
{
1315
$this->theme = $theme;
1416
}

src/Events/ThemeEnabling.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
namespace Hexadog\ThemesManager\Events;
66

7+
use Hexadog\ThemesManager\Theme;
8+
79
class ThemeEnabling
810
{
9-
public array|string $theme;
11+
public Theme $theme;
1012

11-
public function __construct($theme)
13+
public function __construct(Theme $theme)
1214
{
1315
$this->theme = $theme;
1416
}

src/Theme.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public function getVendor(): string
200200
*/
201201
public function hasParent(): bool
202202
{
203-
return ! is_null($this->parent);
203+
return !is_null($this->parent);
204204
}
205205

206206
/**
@@ -250,7 +250,7 @@ public function getScreenshotImageBase64(): ?string
250250
{
251251
$screenshotImage = $this->getAssetsPath($this->screenshot);
252252

253-
if (! is_file($screenshotImage)) {
253+
if (!is_file($screenshotImage)) {
254254
return null;
255255
}
256256

@@ -270,7 +270,7 @@ public function enabled(): bool
270270
*/
271271
public function disabled(): bool
272272
{
273-
return ! $this->enabled();
273+
return !$this->enabled();
274274
}
275275

276276
/**
@@ -281,13 +281,13 @@ public function disable(bool $withEvent = true): Theme
281281
// Check if current is active and currently enabled
282282
if ($this->enabled()) {
283283
if ($withEvent) {
284-
event(new ThemeDisabling($this->name));
284+
event(new ThemeDisabling($this));
285285
}
286286

287287
$this->enabled = false;
288288

289289
if ($withEvent) {
290-
event(new ThemeDisabled($this->name));
290+
event(new ThemeDisabled($this));
291291
}
292292
}
293293

@@ -302,15 +302,15 @@ public function enable(bool $withEvent = true): Theme
302302
// Check if current is active and currently disabled
303303
if ($this->disabled()) {
304304
if ($withEvent) {
305-
event(new ThemeEnabling($this->name));
305+
event(new ThemeEnabling($this));
306306
}
307307

308308
$this->enabled = true;
309309
$this->loadViews();
310310
$this->loadTranlastions();
311311

312312
if ($withEvent) {
313-
event(new ThemeEnabled($this->name));
313+
event(new ThemeEnabled($this));
314314
}
315315
}
316316

@@ -387,12 +387,12 @@ protected function assertPublicAssetsPath(): void
387387
$publicThemeVendorPath = dirname($publicThemeAssetsPath);
388388

389389
// Create target public theme vendor directory if required
390-
if (! file_exists($publicThemeVendorPath)) {
390+
if (!file_exists($publicThemeVendorPath)) {
391391
app(Filesystem::class)->makeDirectory($publicThemeVendorPath, 0755, true);
392392
}
393393

394394
// Create target symlink public theme assets directory if required
395-
if (! file_exists($publicThemeAssetsPath)) {
395+
if (!file_exists($publicThemeAssetsPath)) {
396396
if (Config::get('themes-manager.symlink_relative', false)) {
397397
app(Filesystem::class)->relativeLink($themeAssetsPath, rtrim($publicThemeAssetsPath, '/'));
398398
} else {

0 commit comments

Comments
 (0)