silverstripe-framework/tests/php/View/CastingServiceTest/TestDataObject.php
Guy Sartorelli d18c931ecf
API Refactor template layer into its own module
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
2024-10-22 16:15:39 +13:00

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);
}
}