e.g。 这个答案显示如何列表捆绑字段，但是EntityManager被弃用，并且在Drupal 9之前将删除。
I'm finding Drupal 8 a pretty steep learning curve, and quite often when I do find a solution that works PhpStorm tells me that the function I'm using is deprecated.
E.g. this answer shows how to list a bundles fields, however entityManager is deprecated and will removed before Drupal 9.
How long before Drupal 9 will this be removed? Like next week, next month, next year or in several years just before D9 is released.
Do I need to worry about using deprecated functions? Is it best practice to avoid them all together?
I don't have a reference handy, but I had the conversation about removal with one of the Drupal committers this weekend.
Right now, the committers will not remove any functions from core that are marked as deprecated.
Currently, there is no work being done on Drupal 9. When the 9.0.x branch gets forked from 8.x.y, they will start to accept patches against 9.0.x that remove deprecated functions.
However, there is work to remove usage of deprecated functions in core. For example,
format_date() is marked as deprecated. This function will remain until 9.0.0 is released, and it will never actually be removed from any 8.x.y version. However, patches against 8.x.y will be accepted to replace
format_date() in core with use of the date formatter service. And, in general, no new usages of deprecated functions are allowed in patches (there are some small exceptions for this for consistency sake, mainly in tests).
Should you use them? In general, no. Typically, a deprecated function was a placeholder from Drupal 7 while Drupal 8 was being developed that didn't get replaced (eg,
format_date()), or left for backwards compatibility as Drupal 8 got refactored (eg, the Entity Manager service). Nearly all of the docs on deprecated functions describe what should be done instead. In PhpStorm, Command-B will take you to the function definition, and Command-[ will take you back to where you were.