mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
d18c931ecf
Includes the following large-scale changes: - Impoved barrier between model and view layers - Improved casting of scalar to relevant DBField types - Improved capabilities for rendering arbitrary data in templates
31 lines
742 B
PHP
31 lines
742 B
PHP
<?php
|
|
|
|
namespace SilverStripe\View\Tests\CastingServiceTest;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
class TestDataObject extends DataObject implements TestOnly
|
|
{
|
|
private static string $table_name = 'CastingServiceTest_TestDataObject';
|
|
|
|
private static array $db = [
|
|
'HtmlField' => 'HTMLText',
|
|
'DateField' => 'Date',
|
|
];
|
|
|
|
private static array $casting = [
|
|
'DateField' => 'Text', // won't override
|
|
'TimeField' => 'Time',
|
|
'ArrayAsText' => 'Text',
|
|
];
|
|
|
|
public function castingHelper(string $field): ?string
|
|
{
|
|
if ($field === 'OverrideCastingHelper') {
|
|
return 'Currency';
|
|
}
|
|
return parent::castingHelper($field);
|
|
}
|
|
}
|