|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author @jenschude <[email protected]> |
|
4
|
|
|
*/ |
|
5
|
|
|
|
|
6
|
|
|
namespace Commercetools\Core\Model\Common; |
|
7
|
|
|
|
|
8
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObject; |
|
9
|
|
|
use Commercetools\Core\Model\CustomField\CustomFieldObjectDraft; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* @package Commercetools\Core\Model\Common |
|
13
|
|
|
* |
|
14
|
|
|
* @method AssetSourceCollection getSources() |
|
15
|
|
|
* @method AssetDraft setSources(AssetSourceCollection $sources = null) |
|
16
|
|
|
* @method LocalizedString getName() |
|
17
|
|
|
* @method AssetDraft setName(LocalizedString $name = null) |
|
18
|
|
|
* @method LocalizedString getDescription() |
|
19
|
|
|
* @method AssetDraft setDescription(LocalizedString $description = null) |
|
20
|
|
|
* @method array getTags() |
|
21
|
|
|
* @method AssetDraft setTags(array $tags = null) |
|
22
|
|
|
* @method CustomFieldObjectDraft getCustom() |
|
23
|
|
|
* @method AssetDraft setCustom(CustomFieldObjectDraft $custom = null) |
|
24
|
|
|
* @method string getKey() |
|
25
|
|
|
* @method AssetDraft setKey(string $key = null) |
|
26
|
|
|
*/ |
|
27
|
|
|
class AssetDraft extends JsonObject |
|
28
|
|
|
{ |
|
29
|
17 |
|
public function fieldDefinitions() |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
17 |
|
'key' => [static::TYPE => 'string'], |
|
33
|
17 |
|
'sources' => [static::TYPE => AssetSourceCollection::class], |
|
34
|
17 |
|
'name' => [static::TYPE => LocalizedString::class], |
|
35
|
17 |
|
'description' => [static::TYPE => LocalizedString::class], |
|
36
|
17 |
|
'tags' => [static::TYPE => 'array'], |
|
37
|
17 |
|
'custom' => [static::TYPE => CustomFieldObjectDraft::class], |
|
38
|
|
|
]; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param LocalizedString $name |
|
43
|
|
|
* @param AssetSourceCollection $sources |
|
44
|
|
|
* @param Context|callable $context |
|
45
|
|
|
* @return AssetDraft |
|
46
|
|
|
*/ |
|
47
|
8 |
|
public static function ofNameAndSources(LocalizedString $name, AssetSourceCollection $sources, $context = null) |
|
48
|
|
|
{ |
|
49
|
8 |
|
return static::of($context) |
|
50
|
8 |
|
->setName($name) |
|
51
|
8 |
|
->setSources($sources); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param string $key |
|
56
|
|
|
* @param AssetSourceCollection $sources |
|
57
|
|
|
* @param LocalizedString $name |
|
58
|
|
|
* @param Context|callable $context |
|
59
|
|
|
* @return AssetDraft |
|
60
|
|
|
*/ |
|
61
|
7 |
|
public static function ofKeySourcesAndName( |
|
62
|
|
|
$key, |
|
63
|
|
|
AssetSourceCollection $sources, |
|
64
|
|
|
LocalizedString $name, |
|
65
|
|
|
$context = null |
|
66
|
|
|
) { |
|
67
|
7 |
|
return static::of($context) |
|
68
|
7 |
|
->setKey($key) |
|
69
|
7 |
|
->setSources($sources) |
|
70
|
7 |
|
->setName($name); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|