2016-10-14 03:30:05 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace SilverStripe\Forms\Tests\MoneyFieldTest;
|
|
|
|
|
|
|
|
use SilverStripe\Dev\TestOnly;
|
|
|
|
use SilverStripe\ORM\DataObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Customised class, implementing custom getter and setter methods for
|
|
|
|
* MyMoney.
|
|
|
|
*/
|
|
|
|
class CustomSetter_Object extends DataObject implements TestOnly
|
|
|
|
{
|
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $table_name = 'MoneyFieldTest_CustomSetter_Object';
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
private static $db = array(
|
|
|
|
'MyMoney' => 'Money',
|
|
|
|
);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function getCustomMoney()
|
|
|
|
{
|
|
|
|
return $this->MyMoney->getValue();
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
public function setCustomMoney($value)
|
|
|
|
{
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$newAmount = $value->getAmount() * 2;
|
|
|
|
$this->MyMoney->setAmount($newAmount);
|
2016-10-14 03:30:05 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
$newAmount = $value->getAmount() * 2;
|
|
|
|
$this->MyMoney->setCurrency($value->getCurrency());
|
|
|
|
}
|
2016-10-14 03:30:05 +02:00
|
|
|
}
|