2021-04-22 17:20:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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-05-06 14:00:48 +00:00
|
|
|
use RuntimeException;
|
2021-04-22 17:20:28 +00:00
|
|
|
|
|
|
|
class Actor extends \ActivityPub\Entities\Actor
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var App\Entities\Podcast|null
|
|
|
|
*/
|
|
|
|
protected $podcast;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var boolean
|
|
|
|
*/
|
|
|
|
protected $is_podcast;
|
|
|
|
|
|
|
|
public function getIsPodcast()
|
|
|
|
{
|
|
|
|
return !empty($this->podcast);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPodcast()
|
|
|
|
{
|
|
|
|
if (empty($this->id)) {
|
2021-05-06 14:00:48 +00:00
|
|
|
throw new RuntimeException(
|
2021-04-22 17:20:28 +00:00
|
|
|
'Actor must be created before getting associated podcast.',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($this->podcast)) {
|
|
|
|
$this->podcast = (new PodcastModel())->getPodcastByActorId(
|
|
|
|
$this->id,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->podcast;
|
|
|
|
}
|
|
|
|
}
|