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