Orchard CMS 中每个生命周期事件的定义是什么?

Orchard CMS 中每个生命周期事件的定义是什么?

问题描述:

Orchard 中的内容处理程序文档提到了 Lifecycle Events(http://docs.orchardproject.net/Documentation/Understanding-content-handlers).

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

大多数事件都是不言自明的,但我想知道是否有人可以告诉我 OnActivatedOnInitializingOnLoading 之间的区别?

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

按启动顺序:

  • OnActivated - 已创建内容项对象层次结构,但尚未从数据库中获取

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

用于准备内容部分以供进一步使用.例如.为延迟加载的对象设置 getter 和 setter,设置委托等.把它想象成一个构造函数"对于给定的部分.

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 - 已创建内容项对象层次结构,但尚未从数据库中获取.

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 - 即将从数据库加载内容项.

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

用于各种事物.仅当数据库中存在项目并且即将加载时才触发.Orchard 核心使用此事件为部分记录设置延迟加载器.

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 - 内容项已从数据库加载

OnLoaded - content item has been loaded from db

用于各种事物.仅当数据库中存在项目并且已设置所有记录加载器时才触发.您可以确定此时 part.Record 对于任何部分都不会为 null,并且将包含从数据库中获取的数据.

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.