What are the definitions of each of the Lifecycle Events in Orchard's CMS?

怎甘沉沦 提交于 2019-12-18 03:47:06

问题


The documentation for content handlers in Orchard mentions Lifecycle Events (http://docs.orchardproject.net/Documentation/Understanding-content-handlers).

Most events are self explanatory, but I was wondering if anybody can tell me the differences between OnActivated, OnInitializing, and OnLoading?


回答1:


In firing order:

  • OnActivated - content item object hierarchy has been created, but not yet fetched from db

    Used for preparing content part for further usage. Eg. setting getters and setters for lazy loaded objects, setting up delegates etc. Think of it as of a "constructor" for a given part.

  • OnInitializing - content item object hierarchy has been created, but not yet fetched from db.

    Used for setting initial/default property values for a given part.

  • OnLoading - content item is about to be loaded from db.

    Used for various things. Fired only if an item exists in the database and is about to be loaded. Orchard core uses this event to set up lazy loaders for part records.

  • OnLoaded - content item has been loaded from db

    Used for various things. Fired only if an item exists in the database and all record loaders have been set. You can be sure that part.Record will not be null for any part at this point and will contain data fetched from database.



来源:https://stackoverflow.com/questions/16441705/what-are-the-definitions-of-each-of-the-lifecycle-events-in-orchards-cms

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!