XF 2.2 How does the smilie cache work when searching?

Gobb

Member
Hi all.

I'm looking to create an addon where users can select a small icon image to put before their username. I am intending the selection form to have functionality like the smilie search box in the editor. That's fine and well, but I'm really struggling to understand one part of how this works in particular.
Going from the top:
  • In the editor controller, this is the search action: SmiliesEmojiSearch
  • The database search is conducted via the Emoji Repo: getMatchingEmojiByString
  • In the above function within the Emoji Repo, the following is called: $strFormatter = $this->app()->stringFormatter()
  • After that, the smilies are fetched from the database
  • Now, this is the bit that really is boggling my mind: $data['html'] = $strFormatter->replaceSmiliesHtml($data['shortname']);
Reviewing the function in the Formatter.php file, the cached smilies seem to be fetched here: $cache = &$this->smilieCache? I don't understand how the cached smilies are being fetched though, because smilieCache doesn't seem to line up with any naming I can find within the App.php file, data registry database, etc.

Do I even need to worry about recreating some sort of caching system for my addon's searcher? To give some context, there is probably up to 15 members online on our small forum during a 24 hour period, and the searching function of the addon is likely to be used not all too frequently.

I understand after the icons are fetched from the database, and matched based on the search term entered, I can just return the desired html, but I'm just concerned this wouldn't be the "correct" process. Following XenForo's original files, it seems to be using cached info to build the html, unless I'm not understanding this?

Any insight would be appreciated.
Thanks :)

Edit: I think I've figured it out that's it's called within the rebuildSmilieCache function of the Entity. I'd still like an opinion if it would be worth me trying to figure out how to get this working, or if it's simply better for me to skip trying to replicate it.
 
Last edited:
Depending on how many icons you want to store and offer, it might be simpler to go with the reaction code rather than the smilie code since the latter will also incorporate emoji down the road. You can still hook it up with a select menu like the smilie selector on the frontend, although do keep in mind that since you will not be inside the BB Code editor context, the JS for that cannot be reused without a good chunk of rewrite.
 
Depending on how many icons you want to store and offer, it might be simpler to go with the reaction code rather than the smilie code since the latter will also incorporate emoji down the road. You can still hook it up with a select menu like the smilie selector on the frontend, although do keep in mind that since you will not be inside the BB Code editor context, the JS for that cannot be reused without a good chunk of rewrite.
Appreciate the response, Lukas. I'll review the reaction code tomorrow as it's fairly late here currently. I do have what I want fully functional including the JS already, just with hardcoded font awesome Icons, so no issues if I do need to re-write things to work with the different method. I'm sure I can re-use part of what I already have. Thanks for the suggestion. :)
 
Top Bottom