mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-14 20:17:46 +02:00
refactor: update code base to php 8 and set phpstan lvl to 6
This commit is contained in:
parent
4a33c50fb6
commit
6b74a9e98a
124 changed files with 1810 additions and 2157 deletions
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
namespace App\Controllers;
|
||||
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use Config\Services;
|
||||
use Analytics\AnalyticsTrait;
|
||||
use App\Entities\Episode;
|
||||
use App\Entities\Podcast;
|
||||
|
|
@ -30,25 +32,25 @@ class EpisodeController extends BaseController
|
|||
*/
|
||||
protected $episode;
|
||||
|
||||
public function _remap($method, ...$params)
|
||||
public function _remap(string $method, string ...$params): mixed
|
||||
{
|
||||
if (count($params) < 2) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
!($this->podcast = (new PodcastModel())->getPodcastByName(
|
||||
($this->podcast = (new PodcastModel())->getPodcastByName(
|
||||
$params[0],
|
||||
))
|
||||
)) === null
|
||||
) {
|
||||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
if (
|
||||
$this->episode = (new EpisodeModel())->getEpisodeBySlug(
|
||||
($this->episode = (new EpisodeModel())->getEpisodeBySlug(
|
||||
$this->podcast->id,
|
||||
$params[1],
|
||||
)
|
||||
)) !== null
|
||||
) {
|
||||
unset($params[1]);
|
||||
unset($params[0]);
|
||||
|
|
@ -58,7 +60,7 @@ class EpisodeController extends BaseController
|
|||
throw PageNotFoundException::forPageNotFound();
|
||||
}
|
||||
|
||||
public function index()
|
||||
public function index(): string
|
||||
{
|
||||
// Prevent analytics hit when authenticated
|
||||
if (!can_user_interact()) {
|
||||
|
|
@ -71,17 +73,9 @@ class EpisodeController extends BaseController
|
|||
(can_user_interact() ? '_authenticated' : '');
|
||||
|
||||
if (!($cachedView = cache($cacheName))) {
|
||||
helper('persons');
|
||||
$episodePersons = [];
|
||||
construct_person_array($this->episode->persons, $episodePersons);
|
||||
$podcastPersons = [];
|
||||
construct_person_array($this->podcast->persons, $podcastPersons);
|
||||
|
||||
$data = [
|
||||
'podcast' => $this->podcast,
|
||||
'episode' => $this->episode,
|
||||
'episodePersons' => $episodePersons,
|
||||
'persons' => $podcastPersons,
|
||||
];
|
||||
|
||||
$secondsToNextUnpublishedEpisode = (new EpisodeModel())->getSecondsToNextUnpublishedEpisode(
|
||||
|
|
@ -91,22 +85,22 @@ class EpisodeController extends BaseController
|
|||
if (can_user_interact()) {
|
||||
helper('form');
|
||||
return view('podcast/episode_authenticated', $data);
|
||||
} else {
|
||||
// The page cache is set to a decade so it is deleted manually upon podcast update
|
||||
return view('podcast/episode', $data, [
|
||||
'cache' => $secondsToNextUnpublishedEpisode
|
||||
? $secondsToNextUnpublishedEpisode
|
||||
: DECADE,
|
||||
'cache_name' => $cacheName,
|
||||
]);
|
||||
}
|
||||
// The page cache is set to a decade so it is deleted manually upon podcast update
|
||||
return view('podcast/episode', $data, [
|
||||
'cache' => $secondsToNextUnpublishedEpisode
|
||||
? $secondsToNextUnpublishedEpisode
|
||||
: DECADE,
|
||||
'cache_name' => $cacheName,
|
||||
]);
|
||||
}
|
||||
|
||||
return $cachedView;
|
||||
}
|
||||
|
||||
public function embeddablePlayer($theme = 'light-transparent')
|
||||
{
|
||||
public function embeddablePlayer(
|
||||
string $theme = 'light-transparent'
|
||||
): string {
|
||||
header('Content-Security-Policy: frame-ancestors https://* http://*');
|
||||
|
||||
// Prevent analytics hit when authenticated
|
||||
|
|
@ -114,7 +108,7 @@ class EpisodeController extends BaseController
|
|||
$this->registerPodcastWebpageHit($this->episode->podcast_id);
|
||||
}
|
||||
|
||||
$session = \Config\Services::session();
|
||||
$session = Services::session();
|
||||
$session->start();
|
||||
if (isset($_SERVER['HTTP_REFERER'])) {
|
||||
$session->set(
|
||||
|
|
@ -152,7 +146,7 @@ class EpisodeController extends BaseController
|
|||
return $cachedView;
|
||||
}
|
||||
|
||||
public function oembedJSON()
|
||||
public function oembedJSON(): ResponseInterface
|
||||
{
|
||||
return $this->response->setJSON([
|
||||
'type' => 'rich',
|
||||
|
|
@ -174,7 +168,7 @@ class EpisodeController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function oembedXML()
|
||||
public function oembedXML(): ResponseInterface
|
||||
{
|
||||
$oembed = new SimpleXMLElement(
|
||||
"<?xml version='1.0' encoding='utf-8' standalone='yes'?><oembed></oembed>",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue