- 🇦🇺Australia larowlan 🇦🇺🏝.au GMT+10
Adding a new API is a feature request in my book.
Problem:
It doesn't make any sense to me that FieldPluginBase::trimText() in Views and Unicode::truncate() have slightly different but almost identical behaviour. I could understand this when Views was contrib and wanted to implement its own logic, and I understand it could be beneficial for the two functions to have different arguments, but now that Views is in Core, can we merge the two? We already have visibly diverging handling of truncation now that Views uses "..." and Unicode uses "…".
One difference that I can see is that Views handles HTML entities at the end of strings, whereas the Unicode truncate doesn't have a concept of HTML. If that's the only reason to keep the Views truncation kicking around then that functionality should probably be moved to \Drupal\Component\Utility\Html.
Solution:
- Introduce Html::truncate() that mirrors/wraps Unicode::truncate() but handles HTML entities, etc.
- FieldPluginBase::trimText() simply wraps Html::truncate() and/or Unicode::truncate()
Active
9.5
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Adding a new API is a feature request in my book.