From ed7d5582de6eafc4dd8fc3eab5d15fc49b598edd Mon Sep 17 00:00:00 2001 From: Hadlee Lineham Date: Wed, 29 Jul 2020 09:21:29 +1200 Subject: [PATCH 1/5] Making wrap optional --- code/Icon.php | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/code/Icon.php b/code/Icon.php index 46b8d49..3b7d824 100755 --- a/code/Icon.php +++ b/code/Icon.php @@ -1,14 +1,22 @@ tableName, $this->name, 'Varchar(1024)'); } + + public function wrapSvg() { + return true; + } private static $casting = array( 'URL' => 'HTMLFragment', @@ -84,7 +92,16 @@ public function SVG(){ } $svg = file_get_contents($filePath); - return ''.$svg.''; + + + $wrapSVG = $this->wrapSvg(); + $this->extend('updateWrapSVG', $wrapSVG); + + if($wrapSVG){ + $svg =''.$svg.''; + } + + return $svg; } /** @@ -94,4 +111,4 @@ public function SVG(){ public function scaffoldFormField($title = null, $params = null) { return IconField::create($this->name, $title); } -} \ No newline at end of file +} From cb9230f5cd5bba0da1ff71fcc23697c2f3401715 Mon Sep 17 00:00:00 2001 From: Hadlee Lineham Date: Wed, 29 Jul 2020 09:22:50 +1200 Subject: [PATCH 2/5] removing test code --- code/Icon.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code/Icon.php b/code/Icon.php index 3b7d824..fb84a02 100755 --- a/code/Icon.php +++ b/code/Icon.php @@ -1,12 +1,10 @@ Date: Wed, 29 Jul 2020 13:20:54 +1200 Subject: [PATCH 3/5] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 873e9d8..5e882ef 100755 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "jaedb/iconfield", + "name": "toastnz/iconfield", "type": "silverstripe-vendormodule", "description": "Icon field for SilverStripe", "homepage": "http://jamesbarnsley.co.nz", From 5c0f25b8c10d0e8b524378471b8ad4572cb6184d Mon Sep 17 00:00:00 2001 From: priscillay-toast <92568971+priscillay-toast@users.noreply.github.com> Date: Mon, 13 Apr 2026 08:33:31 +1000 Subject: [PATCH 4/5] Refactor IconField to use Director::publicFolder() --- code/IconField.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/IconField.php b/code/IconField.php index 491d2d7..56d225e 100755 --- a/code/IconField.php +++ b/code/IconField.php @@ -2,6 +2,8 @@ namespace Jaedb\IconField; use DirectoryIterator; +use SilverStripe\Control\Director; +use SilverStripe\Core\Path; use SilverStripe\View\Requirements; use SilverStripe\View\ArrayData; use SilverStripe\ORM\ArrayList; @@ -28,7 +30,7 @@ public function __construct($name, $title = null, $sourceFolder = null){ } $icons = array(); - $sourcePath = BASE_PATH.$sourceFolder; + $sourcePath = Path::join(Director::publicFolder(), $sourceFolder); $extensions = array('jpg', 'jpeg', 'png', 'gif', 'bmp', 'svg'); // Scan each directory for files @@ -48,7 +50,7 @@ public function __construct($name, $title = null, $sourceFolder = null){ } $this->source = $icons; - Requirements::css('/resources/jaedb/iconfield/css/IconField.css'); + Requirements::css('/_resources/jaedb/iconfield/css/IconField.css'); } From aedd35870fc2d267cad90110407e5251b894e09d Mon Sep 17 00:00:00 2001 From: priscillay-toast <92568971+priscillay-toast@users.noreply.github.com> Date: Mon, 11 May 2026 09:10:23 +1000 Subject: [PATCH 5/5] update methods requirements --- code/Icon.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/Icon.php b/code/Icon.php index fb84a02..af47bb5 100755 --- a/code/Icon.php +++ b/code/Icon.php @@ -2,13 +2,15 @@ namespace Jaedb\IconField; -use SilverStripe\ORM\DB; use Jaedb\IconField\IconField; +use SilverStripe\Forms\FormField; +use SilverStripe\ORM\DB; use SilverStripe\ORM\FieldType\DBField; class Icon extends DBField { - function requireField() { + function requireField() : void + { DB::require_field($this->tableName, $this->name, 'Varchar(1024)'); } @@ -28,7 +30,8 @@ public function wrapSvg() { * * @return string */ - public function forTemplate() { + public function forTemplate() : string + { return $this->getTag(); } @@ -106,7 +109,8 @@ public function SVG(){ * (non-PHPdoc) * @see DBField::scaffoldFormField() */ - public function scaffoldFormField($title = null, $params = null) { + public function scaffoldFormField(?string $title = null, array $params = []) : FormField + { return IconField::create($this->name, $title); } }