You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've overwritten mapValueObject to get the attributes, but must be doing something wrong:
// from the parentpublicfunctionmapValueObject(string$elementName, string$className)
{
list($namespace) = self::parseClarkNotation($elementName);
$this->elementMap[$elementName] = function (Reader$reader) use ($className, $namespace) {
$properties = [];
// if I call this, then $o comes back with the #text and is what I want, but I need the attributes to figure out the context. If I add this line, I can't figure out how to get the actual value.// $properties = $reader->parseAttributes(); $o = \Sabre\Xml\Deserializer\valueObject($reader, $className, $namespace);
// hacking away here.if ($className == ProfileSetting::class) {
if ($reader->name === '#text') {
$_value = $reader->value;
}
dump($o, $properties, $className, $reader->name, $_value);
}
if (count($properties)) {
if (array_key_exists('fieldWidth', $properties)) {
dd($properties, $o);
}
$o->setAttributes($properties);
}
// foreach($properties as $key=>$value) {// $o->$key = $value;// if (isset($o->{$key})) {// $o->$key = $value;// }// }return$o;
};
$this->classMap[$className] = function (Writer$writer, $valueObject) use ($namespace) {
return\Sabre\Xml\Serializer\valueObject($writer, $valueObject, $namespace);
};
$this->valueObjectMap[$className] = $elementName;
}
I'd like to suggest that this is such a common situation that perhaps you could make that the default, or at least the example. You could put the attributes in a '@attributes' property (like SimpleXML), or some convention like $_, which is probably what I'll do when I figure this out.
Thanks!
Tac
The text was updated successfully, but these errors were encountered:
What an excellent library, thanks for sharing this.
It is mostly working for me, but I'm struggling how to get an element that has a #text value and attributes, e.g.
I've overwritten mapValueObject to get the attributes, but must be doing something wrong:
So I should be able to use in my class
I'd like to suggest that this is such a common situation that perhaps you could make that the default, or at least the example. You could put the attributes in a '@attributes' property (like SimpleXML), or some convention like $_, which is probably what I'll do when I figure this out.
Thanks!
Tac
The text was updated successfully, but these errors were encountered: