Skip to content

Commit

Permalink
Add sorting to storage drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 27, 2024
1 parent 58cd0da commit ceb1cbe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function actionEdit(): ?Response
// Validate the driver so that any errors will be displayed
$storageDriver->validate();

$storageDrivers = CacheStorageHelper::getAllDrivers();
$storageDrivers = $this->sortDriversByDisplayName(CacheStorageHelper::getAllDrivers());

/** @var BaseCacheGenerator $generatorDriver */
$generatorDriver = BaseDriverHelper::createDriver(
Expand Down
2 changes: 2 additions & 0 deletions src/drivers/storage/BaseCacheStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
abstract class BaseCacheStorage extends SavableComponent implements CacheStorageInterface
{
use CacheStorageTrait;

/**
* @event RefreshCacheEvent The event that is triggered before URIs are deleted.
*/
Expand Down
14 changes: 14 additions & 0 deletions src/drivers/storage/CacheStorageTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @copyright Copyright (c) PutYourLightsOn
*/

namespace putyourlightson\blitz\drivers\storage;

trait CacheStorageTrait
{
/**
* @var bool Whether this is a dummy storage drive.
*/
public bool $isDummy = false;
}
6 changes: 6 additions & 0 deletions src/drivers/storage/DummyStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/
class DummyStorage extends BaseCacheStorage
{

/**
* @inheritdoc
*/
Expand All @@ -21,6 +22,11 @@ public static function displayName(): string
return Craft::t('blitz', 'None');
}

/**
* @inerhitdoc
*/
public bool $isDummy = true;

public function get(SiteUriModel $siteUri): string
{
return '';
Expand Down

0 comments on commit ceb1cbe

Please sign in to comment.