Skip to content

Commit 2f148aa

Browse files
committed
change inheritance HtmlProperty from StringProperty to TextProperty to allow SQL type LONGTEXT. Set HtmlProperty type LONGTEXT by default.
1 parent e762f86 commit 2f148aa

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

src/Charcoal/Property/HtmlProperty.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
namespace Charcoal\Property;
44

55
// From 'charcoal-property'
6-
use Charcoal\Property\StringProperty;
6+
use Charcoal\Property\TextProperty;
77

88
/**
99
* HTML Property.
1010
*
1111
* The html property is a specialized string property.
1212
*/
13-
class HtmlProperty extends StringProperty
13+
class HtmlProperty extends TextProperty
1414
{
15+
const DEFAULT_LONG = true;
16+
17+
/**
18+
* @var boolean
19+
*/
20+
protected $long = self::DEFAULT_LONG;
21+
1522
/**
1623
* The available filesystems (used in TinyMCE's elFinder media manager).
1724
*
@@ -67,14 +74,4 @@ public function getAllowHtml()
6774
{
6875
return true;
6976
}
70-
71-
/**
72-
* Get the SQL type (Storage format).
73-
*
74-
* @return string The SQL type
75-
*/
76-
public function sqlType()
77-
{
78-
return 'TEXT';
79-
}
8077
}

src/Charcoal/Property/TextProperty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TextProperty extends StringProperty
1515
/**
1616
* @var boolean
1717
*/
18-
private $long = self::DEFAULT_LONG;
18+
protected $long = self::DEFAULT_LONG;
1919

2020
/**
2121
* @return string

tests/Charcoal/Property/HtmlPropertyTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function testDefaults()
5050
$this->assertTrue($this->obj['allowNull']);
5151
$this->assertTrue($this->obj['allowHtml']);
5252
$this->assertTrue($this->obj['active']);
53+
$this->assertTrue($this->obj['long']);
5354
}
5455

5556
/**
@@ -66,7 +67,11 @@ public function testDefaultMaxLength()
6667
*/
6768
public function testSqlType()
6869
{
70+
$this->obj->setLong(false);
6971
$this->assertEquals('TEXT', $this->obj->sqlType());
72+
73+
$this->obj->setLong(true);
74+
$this->assertEquals('LONGTEXT', $this->obj->sqlType());
7075
}
7176

7277
public function testFilesystem()

0 commit comments

Comments
 (0)