fix: display chapters in episode preview page

fixes #445
This commit is contained in:
Guy Martin 2024-02-26 10:24:49 +00:00 committed by Yassine Doghri
parent 1e208c55ca
commit 797516a2ec
1 changed files with 15 additions and 2 deletions

View File

@ -14,6 +14,7 @@ use App\Entities\Episode;
use App\Models\EpisodeModel;
use CodeIgniter\Exceptions\PageNotFoundException;
use CodeIgniter\HTTP\RedirectResponse;
use Modules\Media\FileManagers\FileManagerInterface;
class EpisodePreviewController extends BaseController
{
@ -66,9 +67,21 @@ class EpisodePreviewController extends BaseController
public function chapters(): RedirectResponse | string
{
return view('episode/preview-chapters', [
$data = [
'podcast' => $this->episode->podcast,
'episode' => $this->episode,
]);
];
if (isset($this->episode->chapters->file_key)) {
/** @var FileManagerInterface $fileManager */
$fileManager = service('file_manager');
$episodeChaptersJsonString = (string) $fileManager->getFileContents($this->episode->chapters->file_key);
$chapters = json_decode($episodeChaptersJsonString, true);
$data['chapters'] = $chapters;
}
helper('form');
return view('episode/preview-chapters', $data);
}
}