Skip to content

Commit d952d25

Browse files
committed
Replaced image method with the screens collection.
1 parent 16373fe commit d952d25

File tree

2 files changed

+9
-19
lines changed

2 files changed

+9
-19
lines changed

src/Mods/Mod/BaseModInfo.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use CPMDB\Mods\Collection\ModCollection;
2020
use CPMDB\Mods\Items\ItemCategory;
2121
use CPMDB\Mods\Items\ItemInfoInterface;
22+
use CPMDB\Mods\Mod\Screenshots\ModScreenshotCollection;
2223
use CPMDB\Mods\Mod\SeeAlso\LinkReference;
2324
use CPMDB\Mods\Tags\TagCollection;
2425

@@ -41,7 +42,6 @@ abstract class BaseModInfo implements ModInfoInterface
4142
protected JSONFile $dataFile;
4243
protected string $uuid;
4344
protected ArrayDataCollection $data;
44-
protected FileInfo $screenFile;
4545
protected string $dataURL;
4646
private BaseCategory $category;
4747
private string $id;
@@ -53,12 +53,6 @@ public function __construct(string $id, BaseCategory $category, ArrayDataCollect
5353
$this->data = $data;
5454
$this->id = $id;
5555
$this->uuid = $category->getID().'.'.$id;
56-
57-
$this->screenFile = FileInfo::factory(sprintf(
58-
'%s/screens/%s.jpg',
59-
$category->getDataFolder(),
60-
$id
61-
));
6256
}
6357

6458
public function getCategory() : BaseCategory
@@ -109,19 +103,15 @@ public function getName() : string
109103
return $this->getRawData()->getString(self::KEY_MOD_NAME);
110104
}
111105

112-
public function hasImage() : bool
113-
{
114-
return $this->screenFile->exists();
115-
}
106+
private ?ModScreenshotCollection $screenCollection = null;
116107

117-
public function getImageURL() : string
108+
public function getScreenshotCollection() : ModScreenshotCollection
118109
{
119-
return $this->category->getScreensURL().'/'.$this->screenFile->getName();
120-
}
110+
if(!isset($this->screenCollection)) {
111+
$this->screenCollection = new ModScreenshotCollection($this);
112+
}
121113

122-
public function getImageFile() : FileInfo
123-
{
124-
return $this->screenFile;
114+
return $this->screenCollection;
125115
}
126116

127117
private ?string $slug = null;

src/Mods/Mod/ModInfoInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use CPMDB\Mods\Collection\ModCollection;
1616
use CPMDB\Mods\Items\ItemCategory;
1717
use CPMDB\Mods\Items\ItemInfoInterface;
18+
use CPMDB\Mods\Mod\Screenshots\ModScreenshotCollection;
1819
use CPMDB\Mods\Mod\SeeAlso\SeeAlsoReferenceInterface;
1920

2021
/**
@@ -40,10 +41,9 @@ public function getModID() : string;
4041
public function getName() : string;
4142
public function getCategory() : BaseCategory;
4243
public function getModCollection() : ModCollection;
43-
public function hasImage() : bool;
4444
public function getDataFile() : JSONFile;
4545
public function getRawData() : ArrayDataCollection;
46-
public function getImageURL() : string;
46+
public function getScreenshotCollection() : ModScreenshotCollection;
4747
public function getSlug() : string;
4848
public function getURL() : string;
4949
/**

0 commit comments

Comments
 (0)