2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Assets\Tests\AssetControlExtensionTest;
|
|
|
|
|
|
|
|
use SilverStripe\Assets\Storage\DBFile;
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
use SilverStripe\ORM\Versioning\Versioned;
|
|
|
|
use SilverStripe\Security\Member;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Versioned object with attached assets
|
|
|
|
*
|
|
|
|
* @property string $Title
|
|
|
|
* @property DBFile $Header
|
|
|
|
* @property DBFile $Download
|
2016-12-16 05:34:21 +01:00
|
|
|
* @mixin Versioned
|
2016-10-14 03:30:05 +02:00
|
|
|
*/
|
|
|
|
class VersionedObject extends DataObject implements TestOnly
|
|
|
|
{
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $extensions = array(
|
|
|
|
Versioned::class
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $db = array(
|
|
|
|
'Title' => 'Varchar(255)',
|
|
|
|
'Header' => "DBFile('image/supported')",
|
|
|
|
'Download' => 'DBFile'
|
|
|
|
);
|
|
|
|
|
|
|
|
private static $table_name = 'AssetControlExtensionTest_VersionedObject';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Member $member
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canView($member = null)
|
|
|
|
{
|
|
|
|
if (!$member) {
|
|
|
|
$member = Member::currentUser();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Expectation that versioned::canView will hide this object in draft
|
|
|
|
$result = $this->extendedCan('canView', $member);
|
|
|
|
if ($result !== null) {
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Open to public
|
|
|
|
return true;
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|