2016-10-14 03:30:05 +02:00
|
|
|
<?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
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
/**
|
|
|
|
* Ensure that File dataobject has the legacy "Filename" field
|
|
|
|
*/
|
|
|
|
private static $db = array(
|
|
|
|
"Filename" => "Text",
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function onBeforeWrite()
|
|
|
|
{
|
|
|
|
// Ensure underlying filename field is written to the database
|
|
|
|
$this->owner->setField('Filename', 'assets/' . $this->owner->generateFilename());
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|