Skip to content

Commit

Permalink
UI 5.1.0 compatibility (#49)
Browse files Browse the repository at this point in the history
* refModel() is deprecated

* tweak some type comments

* entity instead of model
  • Loading branch information
DarkSide666 authored Apr 4, 2024
1 parent 3341a8c commit e910866
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion demos/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
);

$form->onSubmit(static function (Form $form) use ($app) {
$form->model->save();
$form->entity->save();

return $app->layout->jsReload();
});
Expand Down
6 changes: 3 additions & 3 deletions src/Field/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ protected function init(): void

// remove old file, we don't need it
if ($old) {
$m->refModel($this->shortName)->loadBy('token', $old)->delete();
$m->getModel()->getReference($this->shortName)->createTheirModel()->loadBy('token', $old)->delete();
}

// mark new file as linked
if ($new) {
$m->refModel($this->shortName)->loadBy('token', $new)->save(['status' => File::STATUS_LINKED]);
$m->getModel()->getReference($this->shortName)->createTheirModel()->loadBy('token', $new)->save(['status' => File::STATUS_LINKED]);
}
}
};
Expand All @@ -81,7 +81,7 @@ protected function init(): void
$this->onHookToOwnerEntity(Model::HOOK_AFTER_DELETE, function (Model $m) {
$token = $m->get($this->shortName);
if ($token) {
$m->refModel($this->shortName)->loadBy('token', $token)->delete();
$m->getModel()->getReference($this->shortName)->createTheirModel()->loadBy('token', $token)->delete();
}
});
}
Expand Down
10 changes: 5 additions & 5 deletions src/Model/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class File extends Model

public ?string $titleField = 'meta_filename';

/** @const string All uploaded files first get this status */
/** All uploaded files first get this status */
public const STATUS_DRAFT = 'draft';
/** @const string When file is linked to some other model */
/** When file is linked to some other model */
public const STATUS_LINKED = 'linked';
/** @const string Used for thumbnail files */
/** Used for thumbnail files */
public const STATUS_THUMB = 'thumb';
/** @const list<string> */
/** List of all statuses */
public const ALL_STATUSES = [
self::STATUS_DRAFT,
self::STATUS_LINKED,
Expand All @@ -41,7 +41,7 @@ class File extends Model
/** Thumbnail image max height in pixels */
protected int $thumbnailMaxHeight = 150;

/** Thumbnail format - supported are png, jpg, gif */
/** @var 'png'|'jpg'|'gif' Thumbnail format */
protected string $thumbnailFormat = 'png';

/** Draft files deleting delay in seconds, to prevent cleaning up unsaved forms */
Expand Down

0 comments on commit e910866

Please sign in to comment.