Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
passchn committed Jun 8, 2023
2 parents 9dcb51b + ee8031a commit ff530ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ bin/cake migrations migrate -p Assets

Now you should have an `assets_assets` and an `assets_phinxlog` table in your database.

> Having issues? Check out [this demo app](https://github.com/passchn/cakephp-assets-example-app/) or the [single commits](https://github.com/passchn/cakephp-assets-example-app/commits/main) to see how to setup the plugin.
## Uploading Files

### AssetsController
Expand All @@ -73,10 +75,7 @@ $this->belongsTo('Userimages')
->setForeignKey('userimage_id')
->setClassName('Assets.Assets');
```
**Changes**
> New in Version 0.1.3: `AssetsAssetsTable` is now `AssetsTable`, `AssetsAsset` is `Asset`.
>
> Don't do this anymore: `->setClassName('Assets.AssetsAssets')`
> This does not work anymore. The `cakephp-bake` plugin from version `2.8` onwards seems to detect that you don't actually have a `userimages` table and will not assume a `belongsTo` relation. You will have to write the code yourself or downgrade to version `2.7`.
You can now put an upload field for your Userimage e.g. in `templates/Users/edit.php`:
```
Expand Down
3 changes: 2 additions & 1 deletion src/Model/Table/AssetsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ public function initialize(array $config): void

$now = new FrozenTime();
$pathInfo = pathinfo((string)$data->getClientFilename());
$basename = preg_replace('#\p{C}+#u', '', $pathInfo['basename']);

return $now->format('ymd') . '-' . $now->format('His') . '_' . $pathInfo['basename'];
return $now->format('ymd') . '-' . $now->format('His') . '_' . $basename;
},
'fields' => [
'dir' => 'directory',
Expand Down

0 comments on commit ff530ce

Please sign in to comment.