How do I grab a viewing user object in a custom field class?

When trying to access $this->getViewer() from within PhabricatorUserTitleField, a null is returned I assume because the viewer object hasn’t been set with $this->setViewer(). However I have no idea how to set it since PhabricatorUserTitleField inherits from a Phobject and not an AphrontController.

I searched for quite a while with my IDE to figure out where exactly to set it and only came up with the realization that initialization of PhabricatorUserTitleField takes place in PhabricatorUserConfigOptions. But that class doesn’t inherit from an AphrontController either. So I can’t set the viewer object from there.

I might just be an idiot. But I still can’t figure how to set it. I’ve already read the code layout docs. Can someone explain to me which class to set the object in?

1 Like