Skip to content

Commit

Permalink
Fix hasOne type mismatch for FileField (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrecek234 authored Dec 7, 2023
1 parent 78009f7 commit 1b7bdca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
],
"homepage": "https://github.com/atk4/filestore",
"require": {
"php": ">=7.4 <8.3",
"php": ">=7.4 <8.4",
"atk4/ui": "dev-develop",
"league/flysystem": "^2.0"
},
"require-release": {
"php": ">=7.4 <8.3",
"php": ">=7.4 <8.4",
"atk4/ui": "~5.0.0",
"league/flysystem": "^2.0"
},
Expand Down
8 changes: 4 additions & 4 deletions demos/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
]))->createEntity()
);

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

return $app->layout->jsReload();
Expand All @@ -62,7 +62,7 @@
'paginator' => false,
]);
$files = new File($app->db, ['flysystem' => $filesystem]);
$gr->menu->addItem('Cleanup Drafts')->on('click', function () use ($gr, $files) {
$gr->menu->addItem('Cleanup Drafts')->on('click', static function () use ($gr, $files) {
$files->cleanupDrafts();

return $gr->jsReload();
Expand All @@ -78,7 +78,7 @@

// custom actions
$callbackDownload = Callback::addTo($app);
$callbackDownload->set(function () use ($crud) {
$callbackDownload->set(static function () use ($crud) {
$id = $crud->getApp()->stickyGet('row_id');
$model = (clone $crud->model);
$model_file = File::assertInstanceOf($model->load($id)->ref('file'));
Expand All @@ -94,7 +94,7 @@
);

$callbackView = Callback::addTo($app);
$callbackView->set(function () use ($crud) {
$callbackView->set(static function () use ($crud) {
$id = $crud->getApp()->stickyGet('row_id');
$model = (clone $crud->model);
$model_file = File::assertInstanceOf($model->load($id)->ref('file'));
Expand Down
1 change: 1 addition & 0 deletions src/Field/FileField.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ protected function init(): void
}

$this->reference = HasOneSql::assertInstanceOf($this->getOwner()->hasOne($this->shortName, [
'type' => $this->fileModel->getField('token')->type, // TODO imply in https://github.com/atk4/data/blob/develop/src/Reference/HasOne.php#L27
'model' => $this->fileModel,
'theirField' => 'token',
]));
Expand Down

0 comments on commit 1b7bdca

Please sign in to comment.