mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-06 09:41:36 +02:00
36 lines
771 B
PHP
36 lines
771 B
PHP
<?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
|
|
{
|
|
|
|
private static $table_name = 'MoneyFieldTest_CustomSetter_Object';
|
|
|
|
private static $db = [
|
|
'MyMoney' => 'Money',
|
|
];
|
|
|
|
public function getCustomMoney()
|
|
{
|
|
return $this->MyMoney->getValue();
|
|
}
|
|
|
|
public function setCustomMoney($value)
|
|
{
|
|
|
|
$newAmount = $value->getAmount() * 2;
|
|
$this->MyMoney->setAmount($newAmount);
|
|
|
|
$newAmount = $value->getAmount() * 2;
|
|
$this->MyMoney->setCurrency($value->getCurrency());
|
|
}
|
|
}
|