I am building a User
entity model so it can send various emails. I would like to be able to use the buildLink()
method inside the RequestContext
to aid in building links inside the emails. Is it possible to get an instance of coldbox.system.web.context.RequestContext
inside of my module? When I attempt to inject an instance of it with wirebox, I get the following error message:
“The CONTROLLER parameter to the init function is required but was not passed in.”
Here’s a simplified example of what I am trying to accomplish:
// User Quick Entity
// send a password reset email to the user
void function emailPasswordReset() {
var email = _wirebox.getInstance( "mailService@cbmailservices" ).newMail(
to = getEmailAddress(),
from = emailSettings.from,
subject = settings.password.reset.emailSubject,
type = "html",
body = renderer.view(
view = "emails/passwordResetRequest",
args = {
emailSubject = settings.password.reset.emailSubject,
preHeader = settings.password.reset.emailPreHeader,
user = this
}
)
);
var mailResult = email.send( email );
}
// the email view will request the password reset link
string function renderPasswordResetLink() {
return _wirebox
.getInstance( "coldbox.system.web.context.RequestContext" )
.buildLink( "login.update", {
emailAddress: getEmailAddress(),
key: getPasswordResetKey()
} );
}