2021-04-22 19:20:28 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @copyright 2020 Podlibre
|
|
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
|
|
* @link https://castopod.org/
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Entities;
|
|
|
|
|
2021-05-12 16:00:25 +02:00
|
|
|
use ActivityPub\Entities\Actor as ActivityPubActor;
|
2021-04-22 19:20:28 +02:00
|
|
|
use App\Models\PodcastModel;
|
2021-05-06 16:00:48 +02:00
|
|
|
use RuntimeException;
|
2021-04-22 19:20:28 +02:00
|
|
|
|
2021-05-12 16:00:25 +02:00
|
|
|
/**
|
|
|
|
* @property Podcast|null $podcast
|
|
|
|
* @property boolean $is_podcast
|
|
|
|
*/
|
|
|
|
class Actor extends ActivityPubActor
|
2021-04-22 19:20:28 +02:00
|
|
|
{
|
2021-05-17 19:11:23 +02:00
|
|
|
protected ?Podcast $podcast = null;
|
2021-05-19 18:35:13 +02:00
|
|
|
|
2021-05-14 19:59:35 +02:00
|
|
|
protected bool $is_podcast;
|
2021-04-22 19:20:28 +02:00
|
|
|
|
2021-05-12 16:00:25 +02:00
|
|
|
public function getIsPodcast(): bool
|
2021-04-22 19:20:28 +02:00
|
|
|
{
|
2021-05-12 16:00:25 +02:00
|
|
|
return $this->podcast !== null;
|
2021-04-22 19:20:28 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 16:00:25 +02:00
|
|
|
public function getPodcast(): ?Podcast
|
2021-04-22 19:20:28 +02:00
|
|
|
{
|
2021-05-12 16:00:25 +02:00
|
|
|
if ($this->id === null) {
|
2021-05-19 18:35:13 +02:00
|
|
|
throw new RuntimeException('Podcast id must be set before getting associated podcast.',);
|
2021-04-22 19:20:28 +02:00
|
|
|
}
|
|
|
|
|
2021-05-12 16:00:25 +02:00
|
|
|
if ($this->podcast === null) {
|
2021-05-19 18:35:13 +02:00
|
|
|
$this->podcast = (new PodcastModel())->getPodcastByActorId($this->id,);
|
2021-04-22 19:20:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->podcast;
|
|
|
|
}
|
|
|
|
}
|