public function appendXmlProperty($key, \DOMNode $parentNode, $printDefaults = false, $printComments = false)
{
if (!$this->canPropertyBeExported($key)) {
return;
}
if (!$this->_defaultProperties) {
$reflection = new \ReflectionClass($this);
$this->_defaultProperties = $reflection->getDefaultProperties();
}
if (!$this->_modelProperties) {
$reflectionModel = new \ReflectionClass(__CLASS__);
$this->_modelProperties = $reflectionModel->getDefaultProperties();
}
$getter = 'get' . ucfirst($key);
if (!method_exists($this, $getter)) {
return;
}
$method = new \ReflectionMethod($this, $getter);
$parameters = $method->getParameters();
if (isset($parameters[0]) && 'orCreate' === $parameters[0]->getName()) {
$val = $this->{$getter}($printDefaults);
} else {
$val = $this->{$getter}();
}
if ($this->_defaultProperties[$key] == $val && (!$printDefaults || in_array($key, $this->excludeDefaults))) {
return;
}
if (array_key_exists($key, $this->_modelProperties)) {
return;
}
$setter = 'append' . ucfirst($key) . 'Xml';
if (is_callable(array($this, $setter))) {
return $this->{$setter}($parentNode, $printDefaults);
} else {
return $this->appendXmlValue($key, $val, $parentNode, null, $printDefaults, $printComments);
}
}