use of org.craftercms.commons.http.RequestContext in project engine by craftercms.
the class RenderComponentDirective method createScriptVariables.
protected Map<String, Object> createScriptVariables(SiteItem component, Map<String, Object> templateModel, Map<String, Object> additionalModel) {
Map<String, Object> variables = new HashMap<>();
RequestContext context = RequestContext.getCurrent();
if (context != null) {
GroovyScriptUtils.addSiteItemScriptVariables(variables, context.getRequest(), context.getResponse(), servletContext, component, templateModel);
if (MapUtils.isNotEmpty(additionalModel)) {
variables.putAll(additionalModel);
}
} else {
throw new IllegalStateException("No current request context found");
}
return variables;
}
use of org.craftercms.commons.http.RequestContext in project engine by craftercms.
the class ConfigAwareTestBase method setCurrentRequestContext.
private void setCurrentRequestContext() {
MockHttpServletRequest request = new MockHttpServletRequest("GET", "/");
request.setPathInfo("/");
MockHttpServletResponse response = new MockHttpServletResponse();
RequestContext context = new RequestContext(request, response, null);
RequestContext.setCurrent(context);
}
Aggregations