From 2ceff25440a2155d98b2890fd6387054a6b472c3 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 15 Apr 2023 14:12:43 +0200 Subject: [PATCH 1/4] Use enum instead of constants for SmartAlbumTypes --- app/Enum/DecorateBackedEnum.php | 60 +++++++++++++++++++++++++++++ app/Enum/SmartAlbumType.php | 17 +++++++++ app/Factories/AlbumFactory.php | 61 ++++++++++++------------------ app/Policies/AlbumPolicy.php | 6 +-- app/Rules/AlbumIDListRule.php | 4 +- app/Rules/AlbumIDRule.php | 6 +-- app/SmartAlbums/BaseSmartAlbum.php | 7 ++-- app/SmartAlbums/OnThisDayAlbum.php | 6 +-- app/SmartAlbums/PublicAlbum.php | 6 +-- app/SmartAlbums/RecentAlbum.php | 6 +-- app/SmartAlbums/StarredAlbum.php | 6 +-- app/SmartAlbums/UnsortedAlbum.php | 6 +-- 12 files changed, 128 insertions(+), 63 deletions(-) create mode 100644 app/Enum/DecorateBackedEnum.php create mode 100644 app/Enum/SmartAlbumType.php diff --git a/app/Enum/DecorateBackedEnum.php b/app/Enum/DecorateBackedEnum.php new file mode 100644 index 00000000000..9dbddb9e9d3 --- /dev/null +++ b/app/Enum/DecorateBackedEnum.php @@ -0,0 +1,60 @@ + 1, 'Failed' => 2, 'Success' => 3] + */ +trait DecorateBackedEnum +{ + /** + * Returns a list of name covered by the enum. + * + * @return array + */ + public static function names(): array + { + return array_column(self::cases(), 'name'); + } + + /** + * Returns a list of values covered by the enum. + * + * @return array + */ + public static function values(): array + { + return array_column(self::cases(), 'value'); + } + + /** + * Returns an associative array [name => value]. + * + * @return array + */ + public static function array(): array + { + return array_combine(self::names(), self::values()); + } +} diff --git a/app/Enum/SmartAlbumType.php b/app/Enum/SmartAlbumType.php new file mode 100644 index 00000000000..cfa719bebbd --- /dev/null +++ b/app/Enum/SmartAlbumType.php @@ -0,0 +1,17 @@ + UnsortedAlbum::class, - StarredAlbum::ID => StarredAlbum::class, - PublicAlbum::ID => PublicAlbum::class, - RecentAlbum::ID => RecentAlbum::class, - OnThisDayAlbum::ID => OnThisDayAlbum::class, + public const BUILTIN_SMARTS_CLASS = [ + SmartAlbumType::UNSORTED->value => UnsortedAlbum::class, + SmartAlbumType::STARRED->value => StarredAlbum::class, + SmartAlbumType::PUBLIC->value => PublicAlbum::class, + SmartAlbumType::RECENT->value => RecentAlbum::class, + SmartAlbumType::ON_THIS_DAY->value => OnThisDayAlbum::class, ]; /** @@ -45,8 +46,9 @@ class AlbumFactory */ public function findAbstractAlbumOrFail(string $albumId, bool $withRelations = true): AbstractAlbum { - if ($this->isBuiltInSmartAlbum($albumId)) { - return $this->createSmartAlbum($albumId, $withRelations); + $smartAlbumType = SmartAlbumType::tryFrom($albumId); + if ($smartAlbumType !== null) { + return $this->createSmartAlbum($smartAlbumType, $withRelations); } return $this->findBaseAlbumOrFail($albumId, $withRelations); @@ -108,16 +110,17 @@ public function findAbstractAlbumsOrFail(array $albumIDs, bool $withRelations = { // Remove root (ID===`null`) and duplicates $albumIDs = array_diff(array_unique($albumIDs), [null]); - $smartAlbumIDs = array_intersect($albumIDs, array_keys(self::BUILTIN_SMARTS)); - $modelAlbumIDs = array_diff($albumIDs, array_keys(self::BUILTIN_SMARTS)); + $smartAlbumIDs = array_intersect($albumIDs, SmartAlbumType::values()); + $modelAlbumIDs = array_diff($albumIDs, SmartAlbumType::values()); $smartAlbums = []; foreach ($smartAlbumIDs as $smartID) { try { - $smartAlbums[] = $this->createSmartAlbum($smartID, $withRelations); - } catch (InvalidSmartIdException $e) { - // InvalidSmartIdException must not be thrown, as search has been limited to self::BUILTIN_SMARTS' - throw LycheeAssertionError::createFromUnexpectedException($e); + $smartAlbumType = SmartAlbumType::from($smartID); + $smartAlbums[] = $this->createSmartAlbum($smartAlbumType, $withRelations); + } catch (\ValueError $e) { + $e2 = new InvalidSmartIdException($smartID); + throw LycheeAssertionError::createFromUnexpectedException($e2); } } @@ -183,45 +186,29 @@ public function findBaseAlbumsOrFail(array $albumIDs, bool $withRelations = true public function getAllBuiltInSmartAlbums(bool $withRelations = true): Collection { $smartAlbums = new Collection(); - foreach (self::BUILTIN_SMARTS as $smartAlbumId => $smartAlbumClass) { + foreach (SmartAlbumType::cases() as $smartAlbumId) { $smartAlbums->put($smartAlbumId, $this->createSmartAlbum($smartAlbumId, $withRelations)); } return $smartAlbums; } - /** - * Checks if the given album ID denotes one of the built-in smart albums. - * - * @param string $albumId - * - * @return bool true, if the album ID refers to a built-in smart album - */ - public function isBuiltInSmartAlbum(string $albumId): bool - { - return array_key_exists($albumId, self::BUILTIN_SMARTS); - } - /** * Returns the instance of the built-in smart album with the designated ID. * - * @param string $smartAlbumId the ID of the smart album - * @param bool $withRelations Eagerly loads the relation - * {@link BaseSmartAlbum::photos()} - * for the smart album + * @param SmartAlbumType $smartAlbumId the ID of the smart album + * @param bool $withRelations Eagerly loads the relation + * {@link BaseSmartAlbum::photos()} + * for the smart album * * @return BaseSmartAlbum * * @throws InvalidSmartIdException */ - public function createSmartAlbum(string $smartAlbumId, bool $withRelations = true): BaseSmartAlbum + public function createSmartAlbum(SmartAlbumType $smartAlbumId, bool $withRelations = true): BaseSmartAlbum { - if (!$this->isBuiltInSmartAlbum($smartAlbumId)) { - throw new InvalidSmartIdException($smartAlbumId); - } - /** @var BaseSmartAlbum $smartAlbum */ - $smartAlbum = call_user_func(self::BUILTIN_SMARTS[$smartAlbumId] . '::getInstance'); + $smartAlbum = call_user_func(self::BUILTIN_SMARTS_CLASS[$smartAlbumId->value] . '::getInstance'); if ($withRelations) { // Just try to get the photos. // This loads the relation from DB and caches it. diff --git a/app/Policies/AlbumPolicy.php b/app/Policies/AlbumPolicy.php index 2567a140123..a5b75db3a92 100644 --- a/app/Policies/AlbumPolicy.php +++ b/app/Policies/AlbumPolicy.php @@ -3,10 +3,10 @@ namespace App\Policies; use App\Contracts\Models\AbstractAlbum; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\LycheeAssertionError; use App\Exceptions\Internal\QueryBuilderException; -use App\Factories\AlbumFactory; use App\Models\BaseAlbumImpl; use App\Models\Configs; use App\Models\Extensions\BaseAlbum; @@ -232,7 +232,7 @@ public function canEditById(User $user, array $albumIDs): bool // Make IDs unique as otherwise count will fail. $albumIDs = array_diff( array_unique($albumIDs), - array_keys(AlbumFactory::BUILTIN_SMARTS), + array_keys(SmartAlbumType::values()), [null] ); @@ -264,7 +264,7 @@ public function canShareWithUsers(?User $user, ?AbstractAlbum $abstractAlbum): b return false; } - if (in_array($abstractAlbum->id, AlbumFactory::BUILTIN_SMARTS, true)) { + if (SmartAlbumType::tryFrom($abstractAlbum->id) !== null) { return false; } diff --git a/app/Rules/AlbumIDListRule.php b/app/Rules/AlbumIDListRule.php index 5630851cf78..2c8bb2f7aa1 100644 --- a/app/Rules/AlbumIDListRule.php +++ b/app/Rules/AlbumIDListRule.php @@ -3,7 +3,7 @@ namespace App\Rules; use App\Constants\RandomID; -use App\Factories\AlbumFactory; +use App\Enum\SmartAlbumType; use Illuminate\Contracts\Validation\ValidationRule; class AlbumIDListRule implements ValidationRule @@ -35,6 +35,6 @@ public function message(): string { return ':attribute must be a comma-separated string of strings with either ' . RandomID::ID_LENGTH . ' characters each or one of the built-in IDs ' . - implode(', ', array_keys(AlbumFactory::BUILTIN_SMARTS)); + implode(', ', SmartAlbumType::values()); } } diff --git a/app/Rules/AlbumIDRule.php b/app/Rules/AlbumIDRule.php index cfe4be9dce3..82c5cd3b13d 100644 --- a/app/Rules/AlbumIDRule.php +++ b/app/Rules/AlbumIDRule.php @@ -3,7 +3,7 @@ namespace App\Rules; use App\Constants\RandomID; -use App\Factories\AlbumFactory; +use App\Enum\SmartAlbumType; use Illuminate\Contracts\Validation\ValidationRule; class AlbumIDRule implements ValidationRule @@ -25,7 +25,7 @@ public function passes(string $attribute, mixed $value): bool return ($value === null && $this->isNullable) || strlen($value) === RandomID::ID_LENGTH || - array_key_exists($value, AlbumFactory::BUILTIN_SMARTS); + array_key_exists($value, SmartAlbumType::values()); } /** @@ -35,6 +35,6 @@ public function message(): string { return ':attribute ' . ' must either be null, a string with ' . RandomID::ID_LENGTH . ' characters or one of the built-in IDs ' . - implode(', ', array_keys(AlbumFactory::BUILTIN_SMARTS)); + implode(', ', SmartAlbumType::values()); } } diff --git a/app/SmartAlbums/BaseSmartAlbum.php b/app/SmartAlbums/BaseSmartAlbum.php index bfe9e972339..bb79799b2d2 100644 --- a/app/SmartAlbums/BaseSmartAlbum.php +++ b/app/SmartAlbums/BaseSmartAlbum.php @@ -5,6 +5,7 @@ use App\Contracts\Exceptions\InternalLycheeException; use App\Contracts\Models\AbstractAlbum; use App\DTO\PhotoSortingCriterion; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use App\Exceptions\Internal\InvalidOrderDirectionException; @@ -51,12 +52,12 @@ abstract class BaseSmartAlbum implements AbstractAlbum * @throws ConfigurationKeyMissingException * @throws FrameworkException */ - protected function __construct(string $id, string $title, bool $is_public, \Closure $smartCondition) + protected function __construct(SmartAlbumType $id, bool $is_public, \Closure $smartCondition) { try { $this->photoQueryPolicy = resolve(PhotoQueryPolicy::class); - $this->id = $id; - $this->title = $title; + $this->id = __('lychee.' . $id->name) ?? $id->name; + $this->title = $id->name; $this->is_public = $is_public; $this->grants_download = Configs::getValueAsBool('grants_download'); $this->grants_full_photo_access = Configs::getValueAsBool('grants_full_photo_access'); diff --git a/app/SmartAlbums/OnThisDayAlbum.php b/app/SmartAlbums/OnThisDayAlbum.php index a08b7c7699e..c0ab25e460d 100644 --- a/app/SmartAlbums/OnThisDayAlbum.php +++ b/app/SmartAlbums/OnThisDayAlbum.php @@ -2,6 +2,7 @@ namespace App\SmartAlbums; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use App\Models\Configs; @@ -13,7 +14,7 @@ class OnThisDayAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = 'on_this_day'; + public const ID = SmartAlbumType::ON_THIS_DAY->value; /** * @throws InvalidFormatException @@ -26,8 +27,7 @@ protected function __construct() $today = Carbon::today(); parent::__construct( - self::ID, - __('lychee.ON_THIS_DAY'), + SmartAlbumType::ON_THIS_DAY, Configs::getValueAsBool('public_on_this_day'), function (Builder $query) use ($today) { $query->where(fn (Builder $q) => $q diff --git a/app/SmartAlbums/PublicAlbum.php b/app/SmartAlbums/PublicAlbum.php index 4cdb0964ef2..7dede68baa4 100644 --- a/app/SmartAlbums/PublicAlbum.php +++ b/app/SmartAlbums/PublicAlbum.php @@ -2,6 +2,7 @@ namespace App\SmartAlbums; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use Illuminate\Database\Eloquent\Builder; @@ -26,7 +27,7 @@ class PublicAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = 'public'; + public const ID = SmartAlbumType::PUBLIC->value; /** * Constructor. @@ -44,8 +45,7 @@ class PublicAlbum extends BaseSmartAlbum protected function __construct() { parent::__construct( - self::ID, - __('lychee.PUBLIC'), + SmartAlbumType::PUBLIC, false, fn (Builder $q) => $q->where('photos.is_public', '=', true) ); diff --git a/app/SmartAlbums/RecentAlbum.php b/app/SmartAlbums/RecentAlbum.php index c53c36b1ab8..6e8d6b5485c 100644 --- a/app/SmartAlbums/RecentAlbum.php +++ b/app/SmartAlbums/RecentAlbum.php @@ -2,6 +2,7 @@ namespace App\SmartAlbums; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use App\Models\Configs; @@ -13,7 +14,7 @@ class RecentAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = 'recent'; + public const ID = SmartAlbumType::RECENT->value; /** * @throws InvalidFormatException @@ -28,8 +29,7 @@ protected function __construct() ); parent::__construct( - self::ID, - __('lychee.RECENT'), + SmartAlbumType::RECENT, Configs::getValueAsBool('public_recent'), function (Builder $query) use ($strRecent) { $query->where('photos.created_at', '>=', $strRecent); diff --git a/app/SmartAlbums/StarredAlbum.php b/app/SmartAlbums/StarredAlbum.php index d806965fc80..292d2068fb2 100644 --- a/app/SmartAlbums/StarredAlbum.php +++ b/app/SmartAlbums/StarredAlbum.php @@ -2,6 +2,7 @@ namespace App\SmartAlbums; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use App\Models\Configs; @@ -10,7 +11,7 @@ class StarredAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = 'starred'; + public const ID = SmartAlbumType::STARRED->value; /** * @throws ConfigurationKeyMissingException @@ -19,8 +20,7 @@ class StarredAlbum extends BaseSmartAlbum protected function __construct() { parent::__construct( - self::ID, - __('lychee.STARRED'), + SmartAlbumType::STARRED, Configs::getValueAsBool('public_starred'), fn (Builder $q) => $q->where('photos.is_starred', '=', true) ); diff --git a/app/SmartAlbums/UnsortedAlbum.php b/app/SmartAlbums/UnsortedAlbum.php index 43948c6f774..09004f8a8eb 100644 --- a/app/SmartAlbums/UnsortedAlbum.php +++ b/app/SmartAlbums/UnsortedAlbum.php @@ -2,6 +2,7 @@ namespace App\SmartAlbums; +use App\Enum\SmartAlbumType; use App\Exceptions\ConfigurationKeyMissingException; use App\Exceptions\Internal\FrameworkException; use Illuminate\Database\Eloquent\Builder; @@ -9,7 +10,7 @@ class UnsortedAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = 'unsorted'; + public const ID = SmartAlbumType::UNSORTED->value; /** * @throws ConfigurationKeyMissingException @@ -18,8 +19,7 @@ class UnsortedAlbum extends BaseSmartAlbum public function __construct() { parent::__construct( - self::ID, - __('lychee.UNSORTED'), + SmartAlbumType::UNSORTED, false, fn (Builder $q) => $q->whereNull('photos.album_id') ); From 8d3fe7dfccabb1a65f5a4cd54c1091a75cd9d6f0 Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 15 Apr 2023 14:19:24 +0200 Subject: [PATCH 2/4] Fix small mistakes --- app/Factories/AlbumFactory.php | 3 ++- app/Rules/AlbumIDRule.php | 2 +- app/SmartAlbums/BaseSmartAlbum.php | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Factories/AlbumFactory.php b/app/Factories/AlbumFactory.php index 4a8d9ce6a5a..a1def53bbbd 100644 --- a/app/Factories/AlbumFactory.php +++ b/app/Factories/AlbumFactory.php @@ -186,8 +186,9 @@ public function findBaseAlbumsOrFail(array $albumIDs, bool $withRelations = true public function getAllBuiltInSmartAlbums(bool $withRelations = true): Collection { $smartAlbums = new Collection(); + /** @var SmartAlbumType $smartAlbumId */ foreach (SmartAlbumType::cases() as $smartAlbumId) { - $smartAlbums->put($smartAlbumId, $this->createSmartAlbum($smartAlbumId, $withRelations)); + $smartAlbums->put($smartAlbumId->value, $this->createSmartAlbum($smartAlbumId, $withRelations)); } return $smartAlbums; diff --git a/app/Rules/AlbumIDRule.php b/app/Rules/AlbumIDRule.php index 82c5cd3b13d..ea585f56c49 100644 --- a/app/Rules/AlbumIDRule.php +++ b/app/Rules/AlbumIDRule.php @@ -25,7 +25,7 @@ public function passes(string $attribute, mixed $value): bool return ($value === null && $this->isNullable) || strlen($value) === RandomID::ID_LENGTH || - array_key_exists($value, SmartAlbumType::values()); + SmartAlbumType::tryFrom($value) !== null; } /** diff --git a/app/SmartAlbums/BaseSmartAlbum.php b/app/SmartAlbums/BaseSmartAlbum.php index bb79799b2d2..14c40821376 100644 --- a/app/SmartAlbums/BaseSmartAlbum.php +++ b/app/SmartAlbums/BaseSmartAlbum.php @@ -56,8 +56,8 @@ protected function __construct(SmartAlbumType $id, bool $is_public, \Closure $sm { try { $this->photoQueryPolicy = resolve(PhotoQueryPolicy::class); - $this->id = __('lychee.' . $id->name) ?? $id->name; - $this->title = $id->name; + $this->id = $id->value; + $this->title = __('lychee.' . $id->name) ?? $id->name; $this->is_public = $is_public; $this->grants_download = Configs::getValueAsBool('grants_download'); $this->grants_full_photo_access = Configs::getValueAsBool('grants_full_photo_access'); From cacfc7bf92936476d4cc38a11964e3f8aef2cb0c Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 15 Apr 2023 14:23:28 +0200 Subject: [PATCH 3/4] fix php8.1 requirement --- app/SmartAlbums/OnThisDayAlbum.php | 4 +++- app/SmartAlbums/PublicAlbum.php | 4 +++- app/SmartAlbums/RecentAlbum.php | 4 +++- app/SmartAlbums/StarredAlbum.php | 4 +++- app/SmartAlbums/UnsortedAlbum.php | 4 +++- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/SmartAlbums/OnThisDayAlbum.php b/app/SmartAlbums/OnThisDayAlbum.php index c0ab25e460d..2fb414ce867 100644 --- a/app/SmartAlbums/OnThisDayAlbum.php +++ b/app/SmartAlbums/OnThisDayAlbum.php @@ -14,7 +14,9 @@ class OnThisDayAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = SmartAlbumType::ON_THIS_DAY->value; + // PHP 8.2 + // public const ID = SmartAlbumType::ON_THIS_DAY->value; + public const ID = 'on_this_day'; /** * @throws InvalidFormatException diff --git a/app/SmartAlbums/PublicAlbum.php b/app/SmartAlbums/PublicAlbum.php index 7dede68baa4..95d8629bf4c 100644 --- a/app/SmartAlbums/PublicAlbum.php +++ b/app/SmartAlbums/PublicAlbum.php @@ -27,7 +27,9 @@ class PublicAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = SmartAlbumType::PUBLIC->value; + // PHP 8.2 + // public const ID = SmartAlbumType::PUBLIC->value; + public const ID = 'public'; /** * Constructor. diff --git a/app/SmartAlbums/RecentAlbum.php b/app/SmartAlbums/RecentAlbum.php index 6e8d6b5485c..43871b97c90 100644 --- a/app/SmartAlbums/RecentAlbum.php +++ b/app/SmartAlbums/RecentAlbum.php @@ -14,7 +14,9 @@ class RecentAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = SmartAlbumType::RECENT->value; + // PHP 8.2 + // public const ID = SmartAlbumType::RECENT->value; + public const ID = 'recent'; /** * @throws InvalidFormatException diff --git a/app/SmartAlbums/StarredAlbum.php b/app/SmartAlbums/StarredAlbum.php index 292d2068fb2..7728f10e828 100644 --- a/app/SmartAlbums/StarredAlbum.php +++ b/app/SmartAlbums/StarredAlbum.php @@ -11,7 +11,9 @@ class StarredAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = SmartAlbumType::STARRED->value; + // PHP 8.2 + // public const ID = SmartAlbumType::STARRED->value; + public const ID = 'starred'; /** * @throws ConfigurationKeyMissingException diff --git a/app/SmartAlbums/UnsortedAlbum.php b/app/SmartAlbums/UnsortedAlbum.php index 09004f8a8eb..b2fa9c96eb5 100644 --- a/app/SmartAlbums/UnsortedAlbum.php +++ b/app/SmartAlbums/UnsortedAlbum.php @@ -10,7 +10,9 @@ class UnsortedAlbum extends BaseSmartAlbum { private static ?self $instance = null; - public const ID = SmartAlbumType::UNSORTED->value; + // PHP 8.2 + // public const ID = SmartAlbumType::UNSORTED->value; + public const ID = 'unsorted'; /** * @throws ConfigurationKeyMissingException From adabfcda5c0c74b1b4139f25e8434ce76a13c7cd Mon Sep 17 00:00:00 2001 From: ildyria Date: Sat, 15 Apr 2023 14:25:39 +0200 Subject: [PATCH 4/4] fix php8.1 requirement --- app/Factories/AlbumFactory.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Factories/AlbumFactory.php b/app/Factories/AlbumFactory.php index a1def53bbbd..dfdb6f98415 100644 --- a/app/Factories/AlbumFactory.php +++ b/app/Factories/AlbumFactory.php @@ -21,12 +21,21 @@ class AlbumFactory { + // PHP 8.2 + // public const BUILTIN_SMARTS_CLASS = [ + // SmartAlbumType::UNSORTED->value => UnsortedAlbum::class, + // SmartAlbumType::STARRED->value => StarredAlbum::class, + // SmartAlbumType::PUBLIC->value => PublicAlbum::class, + // SmartAlbumType::RECENT->value => RecentAlbum::class, + // SmartAlbumType::ON_THIS_DAY->value => OnThisDayAlbum::class, + // ]; + public const BUILTIN_SMARTS_CLASS = [ - SmartAlbumType::UNSORTED->value => UnsortedAlbum::class, - SmartAlbumType::STARRED->value => StarredAlbum::class, - SmartAlbumType::PUBLIC->value => PublicAlbum::class, - SmartAlbumType::RECENT->value => RecentAlbum::class, - SmartAlbumType::ON_THIS_DAY->value => OnThisDayAlbum::class, + 'unsorted' => UnsortedAlbum::class, + 'starred' => StarredAlbum::class, + 'public' => PublicAlbum::class, + 'recent' => RecentAlbum::class, + 'on_this_day' => OnThisDayAlbum::class, ]; /**