Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions code/Icon.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
<?php

namespace Jaedb\IconField;
use SilverStripe\ORM\FieldType\DBField;

use SilverStripe\ORM\DB;
use Jaedb\IconField\IconField;
use SilverStripe\ORM\FieldType\DBField;

class Icon extends DBField {

function requireField() {
DB::require_field($this->tableName, $this->name, 'Varchar(1024)');
}

public function wrapSvg() {
return true;
}

private static $casting = array(
'URL' => 'HTMLFragment',
Expand Down Expand Up @@ -84,7 +90,16 @@ public function SVG(){
}

$svg = file_get_contents($filePath);
return '<span class="icon svg">'.$svg.'</span>';


$wrapSVG = $this->wrapSvg();
$this->extend('updateWrapSVG', $wrapSVG);

if($wrapSVG){
$svg ='<span class="icon svg">'.$svg.'</span>';
}

return $svg;
}

/**
Expand All @@ -94,4 +109,4 @@ public function SVG(){
public function scaffoldFormField($title = null, $params = null) {
return IconField::create($this->name, $title);
}
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "jaedb/iconfield",
"name": "toastnz/iconfield",
"type": "silverstripe-vendormodule",
"description": "Icon field for SilverStripe",
"homepage": "http://jamesbarnsley.co.nz",
Expand Down