}
return $list;
}
+
+ /**helper function for classy objects that calls getPropertyArray if available*/
+ protected static function objectToArray($obj)
+ {
+ if(!is_subclass_of($obj,"WObject"))return null;
+ if(!method_exists($obj,"propertyArray"))return null;
+ return $obj->propertyArray();
+ }
};
?>
//de-serializer
tf.write(classDeserializers(cls).toAscii());
+ //prop to array conversion
+ tf.write(classPropertiesList(cls).toAscii());
+
//end of class
code="\n//end of class\n};\n";
tf.write(code.toAscii());
return code;
}
+QString WocPHPServerOut::classPropertiesList(const WocClass&cls)
+{
+ QString code;
+ QStringList k=cls.propertyNames();
+ code+="public function propertyArray(){\n\treturn array(";
+ for(int i=0;i<k.size();i++){
+ if(i)code+=",";
+ code+="\n\t\t\""+k[i]+"\"=>";
+ //is it a list?
+ if(cls.propertyIsList(k[i])){
+ //lists...
+ //object?
+ if(cls.propertyIsObject(k[i]))
+ code+="array_map(\"WObject::objectToArray\",$this->prop_"+k[i]+")";
+ else
+ code+="$this->prop_"+k[i];
+ }else{
+ //non-lists...
+ //object?
+ if(cls.propertyIsObject(k[i]))
+ code+="WObject::objectToArray($this->prop_"+k[i]+")";
+ else
+ code+="$this->prop_"+k[i];
+ }
+ }
+ code+=");\n}\n";
+
+ return code;
+}
+
QString WocPHPServerOut::classPropertyValidator(const WocClass&cls,QString prop)
{
QString code;
QString classPropertyScalarGetters(const WocClass&,QString);
/**helper: generate setters for sclar properties*/
QString classPropertyScalarSetters(const WocClass&,QString);
+ /**helper: generate the property to array converter, eg. for renderers like for Twig*/
+ QString classPropertiesList(const WocClass&);
/**helper: create info functions (mainly version info) at the start*/
void transInfo();