1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author @jenschude <[email protected]> |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\CustomField; |
7
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\Common\Context; |
9
|
|
|
use Commercetools\Core\Model\Common\JsonObject; |
10
|
|
|
use Commercetools\Core\Model\Type\TypeReference; |
11
|
|
|
use Commercetools\Core\Model\Common\ResourceIdentifier; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @package Commercetools\Core\Model\CustomField |
15
|
|
|
* @link https://docs.commercetools.com/http-api-projects-custom-fields.html#customfieldsdraft |
16
|
|
|
* @method FieldContainer getFields() |
17
|
|
|
* @method CustomFieldObjectDraft setFields(FieldContainer $fields = null) |
18
|
|
|
* @method TypeReference getType() |
19
|
|
|
* @method CustomFieldObjectDraft setType(TypeReference $type = null) |
20
|
|
|
*/ |
21
|
|
|
class CustomFieldObjectDraft extends CustomFieldObject |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @param string $typeKey |
25
|
|
|
* @param Context|callable $context |
26
|
|
|
* @return CustomFieldObjectDraft |
27
|
|
|
*/ |
28
|
5 |
|
public static function ofTypeKey($typeKey, $context = null) |
29
|
|
|
{ |
30
|
5 |
|
$draft = static::of($context)->setType(TypeReference::ofKey($typeKey)); |
31
|
|
|
|
32
|
5 |
|
return $draft; |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @param string $typeKey |
37
|
|
|
* @param FieldContainer $fields |
38
|
|
|
* @param Context|callable $context |
39
|
|
|
* @return CustomFieldObjectDraft |
40
|
|
|
*/ |
41
|
3 |
|
public static function ofTypeKeyAndFields($typeKey, FieldContainer $fields, $context = null) |
42
|
|
|
{ |
43
|
3 |
|
return static::of($context) |
44
|
3 |
|
->setType(TypeReference::ofKey($typeKey)) |
45
|
3 |
|
->setFields($fields); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $typeId |
50
|
|
|
* @param Context|callable $context |
51
|
|
|
* @return CustomFieldObjectDraft |
52
|
|
|
*/ |
53
|
|
|
public static function ofTypeId($typeId, $context = null) |
54
|
|
|
{ |
55
|
|
|
$draft = static::of($context)->setType(TypeReference::ofId($typeId)); |
56
|
|
|
|
57
|
|
|
return $draft; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param TypeReference $type |
62
|
|
|
* @param Context|callable $context |
63
|
|
|
* @return CustomFieldObjectDraft |
64
|
|
|
*/ |
65
|
3 |
|
public static function ofType(TypeReference $type, $context = null) |
66
|
|
|
{ |
67
|
3 |
|
$draft = static::of($context)->setType($type); |
68
|
|
|
|
69
|
3 |
|
return $draft; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param TypeReference $type |
74
|
|
|
* @param FieldContainer $fields |
75
|
|
|
* @param Context|callable $context |
76
|
|
|
* @return CustomFieldObjectDraft |
77
|
|
|
*/ |
78
|
1 |
|
public static function ofTypeAndFields(TypeReference $type, FieldContainer $fields, $context = null) |
79
|
|
|
{ |
80
|
1 |
|
return static::of($context) |
81
|
1 |
|
->setType($type) |
82
|
1 |
|
->setFields($fields); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|