generated from vormkracht10/laravel-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature to create permanent cached blade components
- Loading branch information
1 parent
9011d73
commit 1e200c8
Showing
3 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Vormkracht10\PermanentCache; | ||
|
||
use Illuminate\Support\HtmlString; | ||
use Illuminate\View\Component; | ||
|
||
abstract class CachedComponent extends Component implements Scheduled | ||
{ | ||
use Cached; | ||
|
||
public function resolveView() | ||
{ | ||
if(null !== $cache = $this->get()) { | ||
return new HtmlString($cache); | ||
} | ||
|
||
return parent::resolveView(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,17 +7,17 @@ | |
class PermanentCache | ||
{ | ||
/** | ||
* @var array<class-string, array<class-string<Cached>>> | ||
* @var array<class-string, array<class-string<Cached>, class-string<CachedComponent>>> | ||
*/ | ||
protected array $cachers = []; | ||
|
||
/** | ||
* @param array<int, class-string<Cached>> $cachers | ||
* @param array<int, class-string<Cached>, class-string<CachedComponent>> $cachers | ||
* @return $this | ||
*/ | ||
public function caches(array $cachers): self | ||
Check failure on line 18 in src/PermanentCache.php GitHub Actions / phpstan
|
||
{ | ||
/** @var class-string<Cached> $cacher */ | ||
/** @var <class-string<Cached>, class-string<CachedComponent>> $cacher */ | ||
foreach ($cachers as $cacher) { | ||
Check failure on line 21 in src/PermanentCache.php GitHub Actions / phpstan
|
||
$events = $cacher::getListenerEvents(); | ||
|
||
|