mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2021 from jthomerson/fix_if_link_not_working
FIX: <% if Link %> wasn't working
This commit is contained in:
commit
2f9eaeea41
@ -2643,8 +2643,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
} else if($fieldName == 'ID') {
|
||||
return new PrimaryKey($fieldName, $this);
|
||||
|
||||
// General casting information for items in $db or $casting
|
||||
} else if($helper = $this->castingHelper($fieldName)) {
|
||||
// General casting information for items in $db
|
||||
} else if($helper = $this->db($fieldName)) {
|
||||
$obj = Object::create_from_string($helper, $fieldName);
|
||||
$obj->setValue($this->$fieldName, $this->record, false);
|
||||
return $obj;
|
||||
|
@ -165,6 +165,18 @@ SS;
|
||||
'Permissions template functions result correct result');
|
||||
}
|
||||
|
||||
public function testNonFieldCastingHelpersNotUsedInHasValue() {
|
||||
// check if Link without $ in front of variable
|
||||
$result = $this->render(
|
||||
'A<% if Link %>$Link<% end_if %>B', new SSViewerTest_Object());
|
||||
$this->assertEquals('Asome/url.htmlB', $result, 'casting helper not used for <% if Link %>');
|
||||
|
||||
// check if Link with $ in front of variable
|
||||
$result = $this->render(
|
||||
'A<% if $Link %>$Link<% end_if %>B', new SSViewerTest_Object());
|
||||
$this->assertEquals('Asome/url.htmlB', $result, 'casting helper not used for <% if $Link %>');
|
||||
}
|
||||
|
||||
public function testLocalFunctionsTakePriorityOverGlobals() {
|
||||
$data = new ArrayData(array(
|
||||
'Page' => new SSViewerTest_Object()
|
||||
@ -1274,6 +1286,11 @@ class SSViewerTest_Object extends DataObject {
|
||||
|
||||
public $number = null;
|
||||
|
||||
private static $casting = array(
|
||||
'Link' => 'Text',
|
||||
);
|
||||
|
||||
|
||||
public function __construct($number = null) {
|
||||
parent::__construct();
|
||||
$this->number = $number;
|
||||
@ -1290,6 +1307,10 @@ class SSViewerTest_Object extends DataObject {
|
||||
public function lotsOfArguments11($a, $b, $c, $d, $e, $f, $g, $h, $i, $j, $k) {
|
||||
return $a. $b. $c. $d. $e. $f. $g. $h. $i. $j. $k;
|
||||
}
|
||||
|
||||
public function Link() {
|
||||
return 'some/url.html';
|
||||
}
|
||||
}
|
||||
|
||||
class SSViewerTest_GlobalProvider implements TemplateGlobalProvider, TestOnly {
|
||||
|
Loading…
Reference in New Issue
Block a user