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.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/WpfTest/Model/Actor.php b/WpfTest/Model/Actor.php
index eaef99c..0b0e729 100644
--- a/WpfTest/Model/Actor.php
+++ b/WpfTest/Model/Actor.php
@@ -1,9 +1,9 @@
<?php
namespace WpfTest\Model;
-use WpfTest\Model;
+use WpfTest\RemoteFetchable;
-class Actor extends Model implements \JsonSerializable {
+class Actor extends FetchableModel implements \JsonSerializable {
public ?int $id;
public string $uri;
public bool $isLocal = false;
@@ -20,6 +20,14 @@ class Actor extends Model implements \JsonSerializable {
public ActorEndpoints $endpoints;
public array $extensions = [];
+ protected function getUpdateWhereClause(\PDO $db): ?string {
+ if (self::findWhere('uri = ?', [$this->uri]) != null)
+ return 'uri = ' . $db->quote($this->uri);
+ if (self::findWhere('id = ?', [$this->id]) != null)
+ return "id = $this->id";
+ return null;
+ }
+
public static function findLocalByHandle(string $handle): ?self {
return self::findWhere('is_local = true AND handle = ?', [$handle]);
}
@@ -42,4 +50,8 @@ class Actor extends Model implements \JsonSerializable {
]
];
}
+
+ public function hydrate() {
+ $this->endpoints = ActorEndpoints::findWhere('actor_id = ?', [$this->id]);
+ }
} \ No newline at end of file