XF 2.1 How do I get a phrase?

piersg

Member
I am logging a user in to Xenforo from an external CMS
I call $user = $loginService->validate($password, $error);
and if incorrect, the variable $error returns as an XF\Phrase Object.
One of the values of this object is, for example, "[name:protected] => incorrect_password" which is the phrase "Incorrect password. Please try again."
Is there a "proper" way to look up the phrase_text without resorting to a database query, something like
$error_message = XF::phrase($error->name)
Thanks for your advice!
 
To answer my own question, if it helps anyone else:
$error_message = \XF::phrase($error->getName());
seems to work.
 
Back
Top Bottom