Skip to content

Commit

Permalink
change method name
Browse files Browse the repository at this point in the history
  • Loading branch information
nivv committed Jul 2, 2024
1 parent dfdc7cd commit 90f694f
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion config/fabriq.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@

'webhooks' => [
'enabled' => env('FABRIQ_WEBHOOK_ENABLED', true),
'secret' => env('FABRIQ_WEBHOOK_SECRET'),
'secret' => env('FABRIQ_WEBHOOK_SECRET', 'very_secret'),
'endpoint' => env('FABRIQ_WEBHOOK_ENDPOINT'),
],
];
2 changes: 1 addition & 1 deletion src/Listeners/FlushTagCacheListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
*/
public function handle($event)
{
$tagsToFlush = $event->model->getRevisionOptions()->cacheTagsToFlush;
$tagsToFlush = $event->model->getRevisionOptions()->cacheKeysToFlush;

if (! $tagsToFlush) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function getRevisionOptions(): RevisionOptions
return RevisionOptions::create()
->registerDefaultTemplate('article')
->registerSpecialTypes(['image'])
->registerCacheTagsToFlush(['fabriq_articles', 'fabriq_articles|slug'])
->registerCacheKeysToFlush(['fabriq_articles', 'fabriq_articles|slug'])
->registerGetters([
'image' => 'getImages',
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getRevisionOptions(): RevisionOptions
return RevisionOptions::create()
->registerDefaultTemplate('contact')
->registerSpecialTypes(['image'])
->registerCacheTagsToFlush(['fabriq_contacts'])
->registerCacheKeysToFlush(['fabriq_contacts'])
->registerGetters([
'image' => 'getImages',
]);
Expand Down
10 changes: 3 additions & 7 deletions src/Models/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function getRevisionOptions(): RevisionOptions
{
return RevisionOptions::create()
->registerDefaultTemplate('menu-item')
->registerCacheTagsToFlush(['fabriq_menu']);
->registerCacheKeysToFlush(['fabriq_menu']);
}

public function page(): BelongsTo
Expand Down Expand Up @@ -140,18 +140,14 @@ public function getRelativePathAttribute(): string
*
* @param mixed $value
*/
public function setTitleAttribute($value): void
{
}
public function setTitleAttribute($value): void {}

/**
* Skip setting page attribute.
*
* @param mixed $value
*/
public function setPageAttribute($value): void
{
}
public function setPageAttribute($value): void {}

public function menu(): BelongsTo
{
Expand Down
2 changes: 1 addition & 1 deletion src/Models/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function getRevisionOptions(): RevisionOptions
'buttons' => 'getButtons',
'smartBlock' => 'getSmartBlock',
])
->registerCacheTagsToFlush(['fabriq_menu', 'fabriq_pages|slug'])
->registerCacheKeysToFlush(['fabriq_menu', 'fabriq_pages|slug'])
->setIndexable(indexable: true, indexableKeys: ['page_title', 'header'], titleKey: 'page_title');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Models/SmartBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getRevisionOptions(): RevisionOptions
'video' => 'getVideos',
])
->registerDefaultTemplate('smart_block')
->registerCacheTagsToFlush(['fabriq_pages', 'fabriq_smart_blocks']);
->registerCacheKeysToFlush(['fabriq_pages', 'fabriq_smart_blocks']);
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/Services/CacheBuster.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

class CacheBuster
{
public function getCacheKeys(Model $model, array $cacheTagsToFlush = []): Collection
public function getCacheKeys(Model $model, array $cacheKeysToFlush = []): Collection
{
if (method_exists($model, 'getRevisionOptions') && count($cacheTagsToFlush) === 0) {
$cacheTagsToFlush = $model->getRevisionOptions()->cacheTagsToFlush;
if (method_exists($model, 'getRevisionOptions') && count($cacheKeysToFlush) === 0) {
$cacheKeysToFlush = $model->getRevisionOptions()->cacheKeysToFlush;
}

/** @var array<string, string> $cacheTagsToFlush */
return collect($cacheTagsToFlush)->map(function ($tag) use ($model) {
/** @var array<string, string> $cacheKeysToFlush */
return collect($cacheKeysToFlush)->map(function ($tag) use ($model) {
$parts = explode('|', $tag);
if (isset($parts[1])) {
$key = $parts[1];
Expand Down
2 changes: 1 addition & 1 deletion tests/MenuItemFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function it_can_update_a_single_menu_item()
Event::assertDispatchedTimes(TranslatedRevisionUpdated::class, 2);
Event::assertDispatched(function (TranslatedRevisionUpdated $event) {
if (get_class($event->model) === Fabriq::getFqnModel('menuItem')) {
return $event->model->getRevisionOptions()->cacheTagsToFlush[0] === 'fabriq_menu';
return $event->model->getRevisionOptions()->cacheKeysToFlush[0] === 'fabriq_menu';
}
});
}
Expand Down

0 comments on commit 90f694f

Please sign in to comment.