Last active
December 15, 2015 06:29
-
-
Save manticorp/5216944 to your computer and use it in GitHub Desktop.
This gist turns doctrine vars in zend framework to their respective set and get function. Just put your column definitions into a #content container and the returned functions will be put in the #result container. Working jsfiddle: http://jsfiddle.net/Manticorp/Sm5PM/11/
This file contains 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
var str = $("#content").html(); | |
var search = /\/\**[\n\r*\*\w @(=}{",)]*\*\/[\r\n\t ]*private *\$(\w*)[ ="\w]*;/g; | |
$("#content").html(""); | |
var result = str.match(search); | |
var getFunc; | |
var setFunc; | |
while (result = search.exec(str)) { | |
getFunc = "\tpublic function set" + capFLet(result[1]) + "($var){\n\t\t$this->" + result[1] + " = $var;\n\t}\n\n"; | |
setFunc = "\tpublic function get" + capFLet(result[1]) + "(){\n\t\treturn $this->" + result[1] + ";\n\t}\n\n"; | |
$("#result").append(getFunc); | |
$("#result").append(setFunc); | |
} | |
function capFLet(string) { | |
return string.charAt(0).toUpperCase() + string.slice(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment