mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
27 lines
624 B
PHP
27 lines
624 B
PHP
<?php
|
|
|
|
namespace SilverStripe\Assets\Tests\FileMigrationHelperTest;
|
|
|
|
use SilverStripe\Assets\File;
|
|
use SilverStripe\Dev\TestOnly;
|
|
use SilverStripe\ORM\DataExtension;
|
|
|
|
/**
|
|
* @property File $owner
|
|
*/
|
|
class Extension extends DataExtension implements TestOnly
|
|
{
|
|
/**
|
|
* Ensure that File dataobject has the legacy "Filename" field
|
|
*/
|
|
private static $db = array(
|
|
"Filename" => "Text",
|
|
);
|
|
|
|
public function onBeforeWrite()
|
|
{
|
|
// Ensure underlying filename field is written to the database
|
|
$this->owner->setField('Filename', 'assets/' . $this->owner->generateFilename());
|
|
}
|
|
}
|