简体   繁体   English

Drupal 8 hook_node_load不起作用

[英]Drupal 8 hook_node_load not working

I am facing the following challenge for porting my module "Country Specific Nodes" to D8. 将模块“国家特定节点”移植到D8时,我面临以下挑战。
I need to finding the right replacement of Drupal 7's hook_node_load in Drupal 8. I tried hook_entity_load as well as hook_ENTITY_TYPE_load , but it returns the Entity objects and not the actual node objects as in D7's hook_node_load . 我需要在Drupal 8中找到Drupal 7的hook_node_load的正确替换。我尝试了hook_entity_loadhook_ENTITY_TYPE_load ,但是它返回Entity对象,而不是D7的hook_node_load的实际节点对象。
Please let me know the right approach to this. 请让我知道正确的方法。 Thanks for reading out and helping. 感谢您的阅读和帮助。

Thanks. 谢谢。

I found the solution for this. 我找到了解决方案。 Use >hook_ENTITY_TYPE_load($entities) for loading nodes. 使用> hook_ENTITY_TYPE_load($ entities)加载节点。 Actually this hook is not called every time a page loads. 实际上,每次页面加载时都不会调用此钩子。 This is called only when the node is accessed or iterated. 仅在访问或迭代节点时才调用它。

Thanks. 谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM