silverstripe-framework/tests/php/Assets/FileMigrationHelperTest/Extension.php

27 lines
624 B
PHP
Raw Normal View History

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
{
/**
* Ensure that File dataobject has the legacy "Filename" field
*/
private static $db = array(
"Filename" => "Text",
);
2016-10-14 03:30:05 +02: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
}