-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathkyCustomFieldOption.php
More file actions
148 lines (131 loc) · 2.86 KB
/
kyCustomFieldOption.php
File metadata and controls
148 lines (131 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?php
/**
* Class for custom fields options.
*
* @author Tomasz Sawicki (https://github.com/Furgas)
* @link http://wiki.kayako.com/display/DEV/REST+-+CustomField
* @since Kayako version 4.40.1079
* @package Object\CustomField
*/
class kyCustomFieldOption extends kyObjectBase
{
protected static $controller = '/Base/CustomField/ListOptions';
protected static $object_xml_name = 'option';
protected $read_only = true;
/**
* Field option identifier.
* @apiField name=customfieldoptionid
* @var int
*/
protected $id;
/**
* Custom field identifier.
* @apiField name=customfieldid
* @var int
*/
protected $field_id;
/**
* Field option value.
* @apiField name=optionvalue
* @var string
*/
protected $value;
/**
* Display order.
* @apiField
* @var int
*/
protected $display_order;
/**
* Is this option selected by default.
* @apiField
* @var bool
*/
protected $is_selected;
/**
* Parent field option identifier (for linked selects).
* @apiField name=parentcustomfieldoptionid
* @var int
*/
protected $parent_option_id;
protected function parseData($data)
{
$this->id = intval($data['_attributes']['customfieldoptionid']);
$this->field_id = intval($data['_attributes']['customfieldid']);
$this->value = $data['_attributes']['optionvalue'];
$this->display_order = $data['_attributes']['displayorder'];
$this->is_selected = intval($data['_attributes']['isselected']) === 0 ? false : true;
$this->parent_option_id = intval($data['_attributes']['parentcustomfieldoptionid']);
}
public static function get()
{
list($id) = func_get_args();
throw new BadMethodCallException(sprintf("You can't get single object of type %s.", get_called_class()));
}
public function refresh()
{
throw new BadMethodCallException(sprintf("You can't refresh object of type %s.", get_called_class()));
}
public function toString()
{
return sprintf("%s (selected by default: %s)", $this->getValue(), $this->getIsSelected() ? "yes" : "no");
}
public function getId($complete = false)
{
return $complete ? array($this->id) : $this->id;
}
/**
* Returns field id.
*
* @return int
* @filterBy
*/
public function getFieldId()
{
return $this->field_id;
}
/**
* Returns option value.
*
* @return string
* @filterBy
* @orderBy
*/
public function getValue()
{
return $this->value;
}
/**
* Returns option display order.
*
* @return int
* @filterBy
* @orderBy
*/
public function getDisplayOrder()
{
return $this->display_order;
}
/**
* Returns whether this option is selected by default.
*
* @return bool
* @filterBy
* @orderBy
*/
public function getIsSelected()
{
return $this->is_selected;
}
/**
* Returns parent option id (for linked selects).
*
* @return int
* @filterBy
* @orderBy
*/
public function getParentOptionId()
{
return $this->parent_option_id;
}
}