diff options
Diffstat (limited to 'Digitigrade/Job/FetchObject.php')
| -rw-r--r-- | Digitigrade/Job/FetchObject.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Digitigrade/Job/FetchObject.php b/Digitigrade/Job/FetchObject.php new file mode 100644 index 0000000..227e05b --- /dev/null +++ b/Digitigrade/Job/FetchObject.php @@ -0,0 +1,25 @@ +<?php +namespace Digitigrade\Job; + +use Digitigrade\Job; +use Digitigrade\Logger; +use Digitigrade\Model\FetchableModel; + +class FetchObject extends Job { + public string $uri; + public string $type; + + public function __construct(string $type, string $uri) { + $this->type = $type; + $this->uri = $uri; + $this->remainingTries = 8; + } + + public function run() { + assert(is_subclass_of($this->type, FetchableModel::class)); + Logger::getInstance()->info("fetching $this->type at $this->uri"); + if ($this->type::findByUri($this->uri, forceRefetch: true) == null) { + throw new \RuntimeException("remote object doesn't seem to exist"); + } + } +}
\ No newline at end of file |
