By claudiu.cristea on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.1.x
Introduced in version:
8.1.0-beta1
Issue links:
Description:
Wherever the targeted file is known to share the same module directory with the calling code (and whose relative position will not change dynamically), don't use drupal_get_path() or ExtensionList::getPath(). Use the __DIR__ constant to build the path to the referred file/directory.
Impacts:
Module developers
Themers
Site templates, recipes and distribution developers
Comments
Do NOT use __DIR__ when
Do NOT use
__DIR__when overriding a path to a template inhook_theme_registry_alter. Since the Twig loader uses the relative path (relative to the Drupal root) of templates as cache key, and__DIR__evaluates to an absolute path, you'll get an error like"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."