Skip to content

Commit

Permalink
Fixed missing revalidation URLs field
Browse files Browse the repository at this point in the history
  • Loading branch information
Tam committed Apr 21, 2023
1 parent c4b7616 commit 4b0ed3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 4.0.1 - 2023-04-21
### Fixed
- Fixed missing revalidation URLs field
14 changes: 9 additions & 5 deletions src/services/Revalidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public function init (): void

Event::on(
Sections::class,
Sections::EVENT_AFTER_SAVE_SECTION,
[$this, 'onAfterSectionSave']
Sections::EVENT_BEFORE_SAVE_SECTION,
[$this, 'onBeforeSectionSave']
);
}

public function onAfterElementSave (ModelEvent $event): void
public function onAfterElementSave (SectionEvent $event): void
{
/** @var Element $element */
$element = $event->sender;
Expand All @@ -70,7 +70,7 @@ public function onAfterRenderTemplate (TemplateEvent $event): void
$this->injectAdditionalUrisTable($event);
}

public function onAfterSectionSave (SectionEvent $event): void
public function onBeforeSectionSave (SectionEvent $event): void
{
if (!empty($event->section))
$this->saveAdditionalURIs($event->section->uid);
Expand All @@ -86,7 +86,7 @@ public function onAfterSectionSave (SectionEvent $event): void
*/
public function injectAdditionalUrisTable (TemplateEvent $event): void
{
if ($event->template !== 'settings/sections/_edit')
if ($event->template !== 'settings/sections/_edit.twig')
return;

$sectionId = $event->variables['sectionId'];
Expand All @@ -111,6 +111,9 @@ public function injectAdditionalUrisTable (TemplateEvent $event): void
],
],
'rows' => $this->getAdditionalURIs($sectionUid, true),
'initJs' => true,
'allowAdd' => true,
'allowDelete' => true,
]);
}

Expand Down Expand Up @@ -164,6 +167,7 @@ public function saveAdditionalURIs (string $sectionUid): void
if ($request->getIsConsoleRequest())
return;

// FIXME: Can add but can't delete
$uris = $request->getBodyParam('bAdditionalRevalidateUris');
$key = "utility-belt.revalidator.uris.$sectionUid";
$config = Craft::$app->getProjectConfig();
Expand Down

0 comments on commit 4b0ed3a

Please sign in to comment.