2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
2024-09-23 04:31:50 +02:00
|
|
|
namespace SilverStripe\Model\Tests\ModelDataTest;
|
2016-10-14 03:30:05 +02:00
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
2024-09-23 04:31:50 +02:00
|
|
|
use SilverStripe\Model\ModelData;
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2024-09-23 04:31:50 +02:00
|
|
|
class Castable extends ModelData implements TestOnly
|
2016-10-14 03:30:05 +02:00
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $default_cast = Caster::class;
|
|
|
|
|
2020-04-20 19:58:09 +02:00
|
|
|
private static $casting = [
|
2016-12-16 05:34:21 +01:00
|
|
|
'alwaysCasted' => RequiresCasting::class,
|
|
|
|
'castedUnsafeXML' => UnescapedCaster::class,
|
|
|
|
'test' => 'Text',
|
2024-06-11 06:49:27 +02:00
|
|
|
'arrayOne' => 'Text',
|
2020-04-20 19:58:09 +02:00
|
|
|
];
|
2016-12-16 05:34:21 +01:00
|
|
|
|
|
|
|
public $test = 'test';
|
|
|
|
|
|
|
|
public $uncastedZeroValue = 0;
|
|
|
|
|
|
|
|
public function alwaysCasted()
|
|
|
|
{
|
|
|
|
return 'alwaysCasted';
|
|
|
|
}
|
|
|
|
|
2024-06-11 06:49:27 +02:00
|
|
|
public function arrayOne()
|
|
|
|
{
|
|
|
|
return ['value1', 'value2'];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function arrayTwo()
|
|
|
|
{
|
|
|
|
return ['value1', 'value2'];
|
|
|
|
}
|
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function noCastingInformation()
|
|
|
|
{
|
|
|
|
return 'noCastingInformation';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function unsafeXML()
|
|
|
|
{
|
|
|
|
return '<foo>';
|
|
|
|
}
|
|
|
|
|
|
|
|
public function castedUnsafeXML()
|
|
|
|
{
|
|
|
|
return $this->unsafeXML();
|
|
|
|
}
|
|
|
|
|
2024-08-28 00:54:31 +02:00
|
|
|
public function forTemplate(): string
|
2016-12-16 05:34:21 +01:00
|
|
|
{
|
|
|
|
return 'castable';
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|