|
@@ 201-220 (lines=20) @@
|
| 198 |
|
* |
| 199 |
|
* @return string The packed value |
| 200 |
|
*/ |
| 201 |
|
protected function pack($attributeCode, $value) |
| 202 |
|
{ |
| 203 |
|
|
| 204 |
|
// load the attibute with the passed code |
| 205 |
|
$attribute = $this->loadAttributeByAttributeCode($attributeCode); |
| 206 |
|
|
| 207 |
|
// pack the value according to the attribute's frontend input type |
| 208 |
|
switch ($attribute[MemberNames::FRONTEND_INPUT]) { |
| 209 |
|
case FrontendInputTypes::MULTISELECT: |
| 210 |
|
return implode($this->getMultipleValueDelimiter(), $value); |
| 211 |
|
break; |
| 212 |
|
|
| 213 |
|
case FrontendInputTypes::BOOLEAN: |
| 214 |
|
return $value === true ? 'true' : 'false'; |
| 215 |
|
break; |
| 216 |
|
|
| 217 |
|
default: |
| 218 |
|
return $value; |
| 219 |
|
} |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
/** |
| 223 |
|
* Unpacks the passed value according to the frontend input type of the attribute with the passed code. |
|
@@ 230-250 (lines=21) @@
|
| 227 |
|
* |
| 228 |
|
* @return mixed The unpacked value |
| 229 |
|
*/ |
| 230 |
|
protected function unpack($attributeCode, $value) |
| 231 |
|
{ |
| 232 |
|
|
| 233 |
|
// load the attibute with the passed code |
| 234 |
|
$attribute = $this->loadAttributeByAttributeCode($attributeCode); |
| 235 |
|
|
| 236 |
|
// unpack the value according to the attribute's frontend input type |
| 237 |
|
switch ($attribute[MemberNames::FRONTEND_INPUT]) { |
| 238 |
|
case FrontendInputTypes::MULTISELECT: |
| 239 |
|
return explode($this->getMultipleValueDelimiter(), $value); |
| 240 |
|
break; |
| 241 |
|
|
| 242 |
|
case FrontendInputTypes::BOOLEAN: |
| 243 |
|
return filter_var($value, FILTER_VALIDATE_BOOLEAN); |
| 244 |
|
break; |
| 245 |
|
|
| 246 |
|
default: |
| 247 |
|
return $value; |
| 248 |
|
} |
| 249 |
|
} |
| 250 |
|
|
| 251 |
|
/** |
| 252 |
|
* Passes the configuration and initializes the serializer. |
| 253 |
|
* |