aboutsummaryrefslogtreecommitdiffhomepage
path: root/WpfTest/Model/Actor.php
diff options
context:
space:
mode:
Diffstat (limited to 'WpfTest/Model/Actor.php')
-rw-r--r--WpfTest/Model/Actor.php25
1 files changed, 22 insertions, 3 deletions
diff --git a/WpfTest/Model/Actor.php b/WpfTest/Model/Actor.php
index cf8d7ca..eaef99c 100644
--- a/WpfTest/Model/Actor.php
+++ b/WpfTest/Model/Actor.php
@@ -3,9 +3,9 @@ namespace WpfTest\Model;
use WpfTest\Model;
-class Actor extends Model {
- public int $id;
- public string $self;
+class Actor extends Model implements \JsonSerializable {
+ public ?int $id;
+ public string $uri;
public bool $isLocal = false;
public \DateTimeImmutable $created;
public ?\DateTimeImmutable $modified;
@@ -23,4 +23,23 @@ class Actor extends Model {
public static function findLocalByHandle(string $handle): ?self {
return self::findWhere('is_local = true AND handle = ?', [$handle]);
}
+
+ public function jsonSerialize(): array {
+ return [
+ 'type' => 'actor',
+ 'self' => path_to_uri("/user/$this->handle"),
+ 'created' => $this->created?->format('c'),
+ 'modified' => $this->modified?->format('c'),
+ 'homepage' => path_to_uri("/$this->handle"),
+ 'handle' => $this->handle,
+ 'displayName' => $this->displayName,
+ 'bio' => $this->bio,
+ 'pronouns' => $this->pronouns,
+ 'automated' => $this->automated,
+ 'endpoints' => [
+ 'basicFeed' => path_to_uri("/user/$this->handle/basicFeed"),
+ 'fullFeed' => path_to_uri("/user/$this->handle/fullFeed")
+ ]
+ ];
+ }
} \ No newline at end of file