silverstripe-framework/tests/php/Forms/MoneyFieldTest/CustomSetter_Object.php

36 lines
776 B
PHP
Raw Normal View History

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
{
private static $table_name = 'MoneyFieldTest_CustomSetter_Object';
2016-10-14 03:30:05 +02:00
private static $db = array(
'MyMoney' => 'Money',
);
2016-10-14 03:30:05 +02:00
public function getCustomMoney()
{
return $this->MyMoney->getValue();
}
2016-10-14 03:30:05 +02:00
public function setCustomMoney($value)
{
2016-10-14 03:30:05 +02:00
$newAmount = $value->getAmount() * 2;
$this->MyMoney->setAmount($newAmount);
2016-10-14 03:30:05 +02:00
$newAmount = $value->getAmount() * 2;
$this->MyMoney->setCurrency($value->getCurrency());
}
2016-10-14 03:30:05 +02:00
}