@Override
public void doFreemarkerGenerate() throws IOException, TemplateException, EnunciateException {
File genDir = getGenerateDir();
if (!enunciate.isUpToDateWithSources(genDir)) {
EnunciateFreemarkerModel model = getModel();
List<TypeDefinition> schemaTypes = new ArrayList<TypeDefinition>();
ExtensionDepthComparator comparator = new ExtensionDepthComparator();
for (SchemaInfo schemaInfo : model.getNamespacesToSchemas().values()) {
for (TypeDefinition typeDefinition : schemaInfo.getTypeDefinitions()) {
int position = Collections.binarySearch(schemaTypes, typeDefinition, comparator);
if (position < 0) {
position = -position - 1;
}
schemaTypes.add(position, typeDefinition);
}
}
model.put("schemaTypes", schemaTypes);
model.put("packages2modules", this.packageToModuleConversions);
ClientPackageForMethod moduleFor = new ClientPackageForMethod(this.packageToModuleConversions);
moduleFor.setUseClientNameConversions(true);
model.put("moduleFor", moduleFor);
ClientClassnameForMethod classnameFor = new ClientClassnameForMethod(this.packageToModuleConversions);
classnameFor.setUseClientNameConversions(true);
model.put("classnameFor", classnameFor);
TypeNameForMethod typeNameFor = new TypeNameForMethod(this.packageToModuleConversions);
typeNameFor.setUseClientNameConversions(true);
model.put("typeNameFor", typeNameFor);
SimpleNameWithParamsMethod simpleNameFor = new SimpleNameWithParamsMethod(classnameFor);
model.put("simpleNameFor", simpleNameFor);
model.put("phpFileName", getSourceFileName());
model.put("findRootElement", new FindRootElementMethod());
model.put("referencedNamespaces", new ReferencedNamespacesMethod());
model.put("prefix", new PrefixMethod());
debug("Generating the PHP data classes...");
URL apiTemplate = isSingleFilePerClass() ? getTemplateURL("api-multiple-files.fmt") : getTemplateURL("api.fmt");
processTemplate(apiTemplate, model);
}