old_hash = $image->hash; $hash = md5_file($tmp_filename); assert($hash !== false, "Failed to hash file $tmp_filename"); $this->new_hash = $hash; } } class ImageReplaceException extends SCoreException { } /** * Request a thumbnail be made for an image object. */ class ThumbnailGenerationEvent extends Event { public bool $generated; /** * Request a thumbnail be made for an image object */ public function __construct( public Image $image, public bool $force = false ) { parent::__construct(); $this->generated = false; } } /* * ParseLinkTemplateEvent: * $link -- the formatted text (with each element URL Escape'd) * $text -- the formatted text (not escaped) * $original -- the formatting string, for reference * $image -- the image who's link is being parsed */ class ParseLinkTemplateEvent extends Event { public string $link; public string $text; public string $original; public Image $image; public function __construct(string $link, Image $image) { parent::__construct(); $this->link = $link; $this->text = $link; $this->original = $link; $this->image = $image; } public function replace(string $needle, ?string $replace): void { if (!is_null($replace)) { $this->link = str_replace($needle, url_escape($replace), $this->link); $this->text = str_replace($needle, $replace, $this->text); } } }