Skip to content

Commit

Permalink
Merge branch 'release/4.0.0-beta.1' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Mar 13, 2022
2 parents e7a7195 + 0290cb4 commit 30cc3f0
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# FastCGI Cache Bust Changelog

## 4.0.0-beta.1 - 2022.03.12

### Added

* Initial Craft CMS 4 compatibility

## 1.0.10 - 2022.03.12

### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/badges/quality-score.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/?branch=v1) [![Code Coverage](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/badges/coverage.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/?branch=v1) [![Build Status](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/badges/build.png?b=v1)](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/build-status/v1) [![Code Intelligence Status](https://scrutinizer-ci.com/g/nystudio107/craft-fastcgicachebust/badges/code-intelligence.svg?b=v1)](https://scrutinizer-ci.com/code-intelligence)

# FastCGI Cache Bust plugin for Craft CMS 3.x
# FastCGI Cache Bust plugin for Craft CMS 4.x

Bust the Nginx FastCGI Cache when entries are saved or created.

Expand All @@ -10,7 +10,7 @@ Related: [FastCGI Cache Bust for Craft 2.x](https://github.com/nystudio107/fastc

## Requirements

This plugin requires Craft CMS 3.0.0 or later.
This plugin requires Craft CMS 4.0.0 or later.

## Installation

Expand All @@ -21,7 +21,7 @@ To install FastCGI Cache Bust, follow these steps:

You can also install FastCGI Cache Bust via the **Plugin Store** in the Craft Control Panel.

FastCGI Cache Bust works on Craft 3.x.
FastCGI Cache Bust works on Craft 4.x.

## Documentation

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-fastcgicachebust",
"description": "Bust the Nginx FastCGI Cache when entries are saved or created.",
"type": "craft-plugin",
"version": "1.0.10",
"version": "4.0.0-beta.1",
"keywords": [
"craft",
"cms",
Expand All @@ -23,7 +23,7 @@
}
],
"require": {
"craftcms/cms": "^3.1.0"
"craftcms/cms": "^4.0.0-beta.1"
},
"autoload": {
"psr-4": {
Expand Down
17 changes: 3 additions & 14 deletions src/FastcgiCacheBust.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@
use craft\base\Element;
use craft\base\Plugin;
use craft\elements\Entry;
use craft\events\DeleteTemplateCachesEvent;
use craft\events\ElementEvent;
use craft\events\RegisterCacheOptionsEvent;
use craft\services\Elements;
use craft\services\TemplateCaches;
use craft\utilities\ClearCaches;
use nystudio107\fastcgicachebust\models\Settings;
use nystudio107\fastcgicachebust\services\Cache as CacheService;
use yii\base\Event;
use yii\base\Exception;
use function get_class;

/**
* Class FastcgiCacheBust
Expand All @@ -41,9 +38,9 @@ class FastcgiCacheBust extends Plugin
// =========================================================================

/**
* @var FastcgiCacheBust
* @var ?FastcgiCacheBust
*/
public static $plugin;
public static ?FastcgiCacheBust $plugin;

// Public Properties
// =========================================================================
Expand Down Expand Up @@ -107,14 +104,6 @@ function (ElementEvent $event): void {
}
}
);
// Handler: TemplateCaches::EVENT_AFTER_DELETE_CACHES
Event::on(
TemplateCaches::class,
TemplateCaches::EVENT_AFTER_DELETE_CACHES,
static function (DeleteTemplateCachesEvent $event): void {
FastcgiCacheBust::$plugin->cache->clearAll();
}
);
// Handler: ClearCaches::EVENT_REGISTER_CACHE_OPTIONS
Event::on(
ClearCaches::class,
Expand Down Expand Up @@ -163,7 +152,7 @@ protected function shouldBustCache(Element $element): bool
/**
* @inheritdoc
*/
protected function createSettingsModel(): \nystudio107\fastcgicachebust\models\Settings
protected function createSettingsModel(): Settings
{
return new Settings();
}
Expand Down
2 changes: 1 addition & 1 deletion src/models/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Settings extends Model
/**
* @var string
*/
public $cachePath = '';
public string $cachePath = '';

// Public Methods
// =========================================================================
Expand Down
3 changes: 1 addition & 2 deletions src/services/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use craft\base\Component;
use craft\helpers\FileHelper;
use nystudio107\fastcgicachebust\FastcgiCacheBust;
use nystudio107\fastcgicachebust\models\Settings;
use yii\base\ErrorException;

/**
Expand All @@ -33,7 +32,7 @@ class Cache extends Component
public function clearAll(): void
{
$settings = FastcgiCacheBust::$plugin->getSettings();
if (!empty($settings) && !empty($settings->cachePath)) {
if ($settings !== null && !empty($settings->cachePath)) {
$cacheDirs = explode(',', $settings->cachePath);
foreach ($cacheDirs as $cacheDir) {
$cacheDir = Craft::parseEnv($cacheDir);
Expand Down

0 comments on commit 30cc3f0

Please sign in to comment.