-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add cache enabling/disabling setting
- Loading branch information
Showing
6 changed files
with
68 additions
and
31 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
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 was deleted.
Oops, something went wrong.
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,38 @@ | ||
<?php | ||
|
||
namespace ACPL\FlarumCache\Listener; | ||
|
||
use ACPL\FlarumCache\Command\LSCacheClearCommand; | ||
use ACPL\FlarumCache\Utility\HtaccessManager; | ||
use Flarum\Settings\Event\Saved; | ||
use Illuminate\Contracts\Filesystem\FileNotFoundException; | ||
use Symfony\Component\Console\Exception\ExceptionInterface; | ||
use Symfony\Component\Console\Input\ArrayInput; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
|
||
class UpdateSettings | ||
{ | ||
protected HtaccessManager $htaccessManager; | ||
protected LSCacheClearCommand $cacheClearCommand; | ||
|
||
public function __construct(HtaccessManager $htaccessManager, LSCacheClearCommand $command) | ||
{ | ||
$this->htaccessManager = $htaccessManager; | ||
$this->cacheClearCommand = $command; | ||
} | ||
|
||
/** | ||
* @throws FileNotFoundException|ExceptionInterface | ||
*/ | ||
public function handle(Saved $event): void | ||
{ | ||
if (isset($event->settings['acpl-lscache.drop_qs'])) { | ||
$this->htaccessManager->updateHtaccess(); | ||
} | ||
|
||
// If the LSCache is being disabled, initiate a cache clear operation. | ||
if (isset($event->settings['acpl-lscache.cache_enabled']) && $event->settings['acpl-lscache.cache_enabled'] === false) { | ||
$this->cacheClearCommand->run(new ArrayInput([]), new NullOutput()); | ||
} | ||
} | ||
} |
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