From 9de58b6993ce7765b1836b30223cccda1782e395 Mon Sep 17 00:00:00 2001 From: Cam Spiers Date: Thu, 9 Jan 2020 14:36:50 +1300 Subject: [PATCH 1/4] first pass at SS4 upgrade --- _config/config.yml | 6 +++--- code/PageFacebookImageExtension.php | 23 +++++++++++++++++++---- code/SiteConfigFacebookImageExtension.php | 17 ++++++++++++++--- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/_config/config.yml b/_config/config.yml index e631e25..ccd30c9 100644 --- a/_config/config.yml +++ b/_config/config.yml @@ -1,7 +1,7 @@ -SiteConfig: +SilverStripe\SiteConfig\SiteConfig: extensions: - - SiteConfigFacebookImageExtension + - WT\FacebookImage\SiteConfigFacebookImageExtension Page: extensions: - - PageFacebookImageExtension \ No newline at end of file + - WT\FacebookImage\PageFacebookImageExtension diff --git a/code/PageFacebookImageExtension.php b/code/PageFacebookImageExtension.php index e72149d..5789822 100644 --- a/code/PageFacebookImageExtension.php +++ b/code/PageFacebookImageExtension.php @@ -1,14 +1,27 @@ 'Image' + 'FacebookImage' => Image::class, ); public function updateCMSFields(FieldList $fields) { - $fields->addFieldToTab('Root.Facebook', $uf = new UploadField('FacebookImage', 'Facebook image for facebook share')); + $fields->addFieldToTab( + 'Root.Facebook', + $uf = new UploadField('FacebookImage', 'Facebook image for facebook share'), + ); + $uf->setFolderName('FacebookImages/'); } @@ -17,7 +30,9 @@ public function updateCMSFields(FieldList $fields) */ public function FacebookImageWithFallback() { - return $this->owner->FacebookImageID ? $this->owner->FacebookImage() : SiteConfig::current_site_config()->FacebookImage(); + return $this->owner->FacebookImageID + ? $this->owner->FacebookImage() + : SiteConfig::current_site_config()->FacebookImage(); } /** @@ -27,4 +42,4 @@ public function FacebookMetaTags() { return Controller::curr()->renderWith('FacebookMetaTags'); } -} \ No newline at end of file +} diff --git a/code/SiteConfigFacebookImageExtension.php b/code/SiteConfigFacebookImageExtension.php index 0f9439e..e26b714 100644 --- a/code/SiteConfigFacebookImageExtension.php +++ b/code/SiteConfigFacebookImageExtension.php @@ -1,15 +1,26 @@ 'Image' + 'FacebookImage' => Image::class, ); public function updateCMSFields(FieldList $fields) { - $fields->addFieldToTab('Root.Facebook', $uf = new UploadField('FacebookImage', 'Default Facebook image for facebook share')); + $fields->addFieldToTab( + 'Root.Facebook', + $uf = new UploadField('FacebookImage', 'Default Facebook image for facebook share'), + ); + $uf->setFolderName('FacebookImages/'); } -} \ No newline at end of file +} From 577c86a81bc531b93dd3c5f12710b2fa77e6e8ba Mon Sep 17 00:00:00 2001 From: Alex Perez Date: Thu, 13 Feb 2020 09:40:39 +1300 Subject: [PATCH 2/4] Remove trailing comma Fixes -> PHP Parse error: syntax error, unexpected ')' --- code/PageFacebookImageExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/PageFacebookImageExtension.php b/code/PageFacebookImageExtension.php index 5789822..6cfee9c 100644 --- a/code/PageFacebookImageExtension.php +++ b/code/PageFacebookImageExtension.php @@ -19,7 +19,7 @@ public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab( 'Root.Facebook', - $uf = new UploadField('FacebookImage', 'Facebook image for facebook share'), + $uf = new UploadField('FacebookImage', 'Facebook image for facebook share') ); $uf->setFolderName('FacebookImages/'); From da12a203f710afa81ef9acec73bdffc9a9c6a084 Mon Sep 17 00:00:00 2001 From: Ben Rhodes Date: Wed, 11 Mar 2020 10:28:06 +1300 Subject: [PATCH 3/4] updated composer to require silverstripe 4, updated readme, added license, updated extensions to use ownership of images. --- LICENSE | 19 +++++++++++++++++++ README.md | 2 +- code/PageFacebookImageExtension.php | 17 +++++++++++++++-- code/SiteConfigFacebookImageExtension.php | 17 +++++++++++++++-- composer.json | 3 ++- 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..e5847b6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +The MIT License (MIT) +Copyright © 2020 Wunderman Thompson New Zealand + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the “Software”), to deal in +the Software without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +and to permit persons to whom the Software is furnished to do so, subject to the +following conditions: + +The above copyright notice and this permission notice shall be included in all copies +or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR +PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE +OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index 8e70d89..a6f8f78 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SilverStripe Facebook Image -This version supports SilverStripe 3, see the 0.0 branch for a SilverStripe 2.4 compatible version. +This version supports SilverStripe 4, see the 0.1 release for a SilverStripe 3 compatible version and the 0.0 release for a SilverStripe 2.4 compatible version. Provides an Image Field for use when sharing pages on facebook. diff --git a/code/PageFacebookImageExtension.php b/code/PageFacebookImageExtension.php index 6cfee9c..a5e7ecc 100644 --- a/code/PageFacebookImageExtension.php +++ b/code/PageFacebookImageExtension.php @@ -11,10 +11,23 @@ class PageFacebookImageExtension extends DataExtension { - private static $has_one = array( + /** + * @var array + */ + private static $has_one = [ 'FacebookImage' => Image::class, - ); + ]; + /** + * @var array + */ + private static $owns = [ + 'FacebookImage', + ]; + + /** + * @param FieldList $fields + */ public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab( diff --git a/code/SiteConfigFacebookImageExtension.php b/code/SiteConfigFacebookImageExtension.php index e26b714..f7bcaeb 100644 --- a/code/SiteConfigFacebookImageExtension.php +++ b/code/SiteConfigFacebookImageExtension.php @@ -9,10 +9,23 @@ class SiteConfigFacebookImageExtension extends DataExtension { - private static $has_one = array( + /** + * @var array + */ + private static $has_one = [ 'FacebookImage' => Image::class, - ); + ]; + /** + * @var array + */ + private static $owns = [ + 'FacebookImage', + ]; + + /** + * @param FieldList $fields + */ public function updateCMSFields(FieldList $fields) { $fields->addFieldToTab( diff --git a/composer.json b/composer.json index 699600a..ec8a25c 100644 --- a/composer.json +++ b/composer.json @@ -9,6 +9,7 @@ } ], "require": { - "composer/installers": "~1.0" + "composer/installers": "~1.0", + "silverstripe/framework": "^4.0.0" } } From 1bbd199683b50578fb678cb5d0116ff1d5f45f7c Mon Sep 17 00:00:00 2001 From: Ben Rhodes Date: Wed, 11 Mar 2020 11:17:27 +1300 Subject: [PATCH 4/4] adding module type as silverstripe-vendormodule in composer.json --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index ec8a25c..72dae71 100644 --- a/composer.json +++ b/composer.json @@ -2,6 +2,7 @@ "name": "heyday/silverstripe-facebookimage", "type": "silverstripe-module", "description": "Provides an Image Field for use when sharing pages on facebook", + "type": "silverstripe-vendormodule", "authors": [ { "name": "Glenn Bautista",