8ddc1af5c0
Grav\Common\Cache has no clear() method in this version; the correct method is deleteAll(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
27 lines
546 B
PHP
27 lines
546 B
PHP
<?php
|
|
namespace Grav\Plugin;
|
|
|
|
use Grav\Common\Plugin;
|
|
use RocketTheme\Toolbox\Event\Event;
|
|
|
|
class CacheOnSavePlugin extends Plugin
|
|
{
|
|
public static function getSubscribedEvents(): array
|
|
{
|
|
return [
|
|
'onFormProcessed' => ['onFormProcessed', 0],
|
|
];
|
|
}
|
|
|
|
public function onFormProcessed(Event $event): void
|
|
{
|
|
$form = $event['form'];
|
|
if (!$form) {
|
|
return;
|
|
}
|
|
if ($form->getName() === 'new-entry') {
|
|
$this->grav['cache']->deleteAll();
|
|
}
|
|
}
|
|
}
|