|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jayS-de <[email protected]> |
|
4
|
|
|
* @created: 04.02.15, 16:43 |
|
5
|
|
|
*/ |
|
6
|
|
|
|
|
7
|
|
|
namespace Commercetools\Core\Model\Common; |
|
8
|
|
|
|
|
9
|
|
|
use Commercetools\Core\Model\Channel\ChannelReference; |
|
10
|
|
|
use Commercetools\Core\Model\CustomerGroup\CustomerGroupReference; |
|
11
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @package Commercetools\Core\Model\Common |
|
15
|
|
|
* @link https://dev.commercetools.com/http-api-projects-products.html#scopedprice |
|
16
|
|
|
* @method Money getValue() |
|
17
|
|
|
* @method string getCountry() |
|
18
|
|
|
* @method CustomerGroupReference getCustomerGroup() |
|
19
|
|
|
* @method ChannelReference getChannel() |
|
20
|
|
|
* @method DiscountedPrice getDiscounted() |
|
21
|
|
|
* @method ScopedPrice setValue(Money $value = null) |
|
22
|
|
|
* @method ScopedPrice setCountry(string $country = null) |
|
23
|
|
|
* @method ScopedPrice setCustomerGroup(CustomerGroupReference $customerGroup = null) |
|
24
|
|
|
* @method ScopedPrice setChannel(ChannelReference $channel = null) |
|
25
|
|
|
* @method ScopedPrice setDiscounted(DiscountedPrice $discounted = null) |
|
26
|
|
|
* @method string getId() |
|
27
|
|
|
* @method ScopedPrice setId(string $id = null) |
|
28
|
|
|
* @method DateTimeDecorator getValidFrom() |
|
29
|
|
|
* @method ScopedPrice setValidFrom(\DateTime $validFrom = null) |
|
30
|
|
|
* @method DateTimeDecorator getValidUntil() |
|
31
|
|
|
* @method ScopedPrice setValidUntil(\DateTime $validUntil = null) |
|
32
|
|
|
* @method CustomFieldObject getCustom() |
|
33
|
|
|
* @method ScopedPrice setCustom(CustomFieldObject $custom = null) |
|
34
|
|
|
* @method Money getCurrentValue() |
|
35
|
|
|
* @method ScopedPrice setCurrentValue(Money $currentValue = null) |
|
36
|
|
|
*/ |
|
37
|
|
|
class ScopedPrice extends Price |
|
38
|
|
|
{ |
|
39
|
|
|
const CURRENT_VALUE = 'currentValue'; |
|
40
|
|
|
|
|
41
|
|
|
public function fieldDefinitions() |
|
42
|
|
|
{ |
|
43
|
|
|
$definitions = parent::fieldDefinitions(); |
|
44
|
|
|
$definitions[static::CURRENT_VALUE] = [static::TYPE => '\Commercetools\Core\Model\Common\Money']; |
|
45
|
|
|
|
|
46
|
|
|
return $definitions; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param Money $money |
|
51
|
|
|
* @param Context|callable $context |
|
52
|
|
|
* @return Price |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function ofMoney(Money $money, $context = null) |
|
55
|
|
|
{ |
|
56
|
|
|
$price = static::of($context); |
|
57
|
|
|
return $price->setValue($money); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function __toString() |
|
61
|
|
|
{ |
|
62
|
|
|
return $this->getCurrentValue()->__toString(); |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|