Created
June 1, 2016 13:44
-
-
Save yuklia/4662bf1212adaa6c81da94819d147d54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function _serializeField(DataObject $object, $field, $defaultValue = null, $unsetEmpty = false) | |
{ | |
$value = $object->getData($field); | |
if (empty($value) && $unsetEmpty) { | |
$object->unsetData($field); | |
} else { | |
if (is_string($value)) { | |
$object->setData($field, $value ?: $defaultValue); | |
} else { | |
$object->setData($field, serialize($value ?: $defaultValue)); | |
} | |
} | |
return $this; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment