From 293bc2cb0b15cdce2a2d113777c55143c0c1fac2 Mon Sep 17 00:00:00 2001 From: Pascal Schneider <77938819+passchn@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:28:04 +0100 Subject: [PATCH 1/6] Update README.md The bake plugin does not assume relations if there is no table anymore. --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index c82f000..d3bcf7d 100644 --- a/README.md +++ b/README.md @@ -73,10 +73,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 now 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. You can now put an upload field for your Userimage e.g. in `templates/Users/edit.php`: ``` From 4ddb7e0a068429ad624c3778e4cf1483fa9df3cb Mon Sep 17 00:00:00 2001 From: Pascal Schneider <77938819+passchn@users.noreply.github.com> Date: Fri, 10 Mar 2023 19:46:17 +0100 Subject: [PATCH 2/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3bcf7d..1832536 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ $this->belongsTo('Userimages') ->setForeignKey('userimage_id') ->setClassName('Assets.Assets'); ``` -> This does not work anymore. The `cakephp-bake` plugin now 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. +> 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`: ``` From 26cac826427040385a140139a2020d7bce068250 Mon Sep 17 00:00:00 2001 From: Pascal Schneider <77938819+passchn@users.noreply.github.com> Date: Fri, 10 Mar 2023 20:17:35 +0100 Subject: [PATCH 3/6] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 1832536..e10d682 100644 --- a/README.md +++ b/README.md @@ -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 From a0b126d0be250712526c4794ed35bb598f4b8e07 Mon Sep 17 00:00:00 2001 From: passchn <77938819+passchn@users.noreply.github.com> Date: Fri, 31 Mar 2023 21:00:25 +0200 Subject: [PATCH 4/6] upgrade cakephp-upload to ^7.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index faa1625..7a72131 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "ext-fileinfo": "*", "cakephp/cakephp": "^4.2", "intervention/image": "^2.7", - "josegonzalez/cakephp-upload": "^6.0", + "josegonzalez/cakephp-upload": "^7.0", "league/csv": "^9.8", "nette/finder": "^2.5", "nette/utils": "^3.2" From 11e54faedfc8662fe25312d1a0f660b1f378a519 Mon Sep 17 00:00:00 2001 From: passchn <77938819+passchn@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:43:21 +0200 Subject: [PATCH 5/6] remove unicode control characters (e.g. soft hyphens) from filenames --- src/Model/Table/AssetsTable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Model/Table/AssetsTable.php b/src/Model/Table/AssetsTable.php index 7b66dcc..bb70f7e 100644 --- a/src/Model/Table/AssetsTable.php +++ b/src/Model/Table/AssetsTable.php @@ -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', From ee8031aae4b1cfe897e7506783a0bf2115ba28d7 Mon Sep 17 00:00:00 2001 From: passchn <77938819+passchn@users.noreply.github.com> Date: Sun, 16 Apr 2023 20:44:39 +0200 Subject: [PATCH 6/6] code style --- src/Model/Table/AssetsTable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/Table/AssetsTable.php b/src/Model/Table/AssetsTable.php index bb70f7e..0593e38 100644 --- a/src/Model/Table/AssetsTable.php +++ b/src/Model/Table/AssetsTable.php @@ -58,9 +58,9 @@ public function initialize(array $config): void $now = new FrozenTime(); $pathInfo = pathinfo((string)$data->getClientFilename()); - $basename = preg_replace('#\p{C}+#u', '', $pathInfo['basename']); + $basename = preg_replace('#\p{C}+#u', '', $pathInfo['basename']); - return $now->format('ymd') . '-' . $now->format('His') . '_' . $basename; + return $now->format('ymd') . '-' . $now->format('His') . '_' . $basename; }, 'fields' => [ 'dir' => 'directory',