Added CreatingDisplay event to ElementDriver.

This commit is contained in:
Sipke Schoorstra
2015-04-19 18:43:05 +02:00
parent 65e951eee1
commit eb6285012a
3 changed files with 14 additions and 4 deletions

View File

@@ -27,6 +27,9 @@ namespace Orchard.Layouts.Framework.Display {
string displayType = null,
IUpdateModel updater = null) {
var typeName = element.GetType().Name;
var category = element.Category.ToSafeName();
var drivers = element.Descriptor.GetDrivers().ToList();
var createShapeContext = new ElementCreatingDisplayShapeContext {
Element = element,
DisplayType = displayType,
@@ -34,14 +37,13 @@ namespace Orchard.Layouts.Framework.Display {
};
_elementEventHandlerHandler.CreatingDisplay(createShapeContext);
element.Descriptor.CreatingDisplay(createShapeContext);
InvokeDrivers(drivers, driver => driver.CreatingDisplay(createShapeContext));
if (element.Descriptor.CreatingDisplay != null)
element.Descriptor.CreatingDisplay(createShapeContext);
if (createShapeContext.Cancel)
return null;
var typeName = element.GetType().Name;
var category = element.Category.ToSafeName();
var drivers = element.Descriptor.GetDrivers().ToList();
var elementShapeArguments = CreateArguments(element, content);
var elementShape = (dynamic)_shapeFactory.Create("Element", elementShapeArguments, () => new ZoneHolding(() => _shapeFactory.Create("ElementZone")));

View File

@@ -17,6 +17,10 @@ namespace Orchard.Layouts.Framework.Drivers {
return OnUpdateEditor((TElement)context.Element, context);
}
public void CreatingDisplay(ElementCreatingDisplayShapeContext context) {
OnCreatingDisplay((TElement)context.Element, context);
}
public void Displaying(ElementDisplayingContext context) {
OnDisplaying((TElement) context.Element, context);
}
@@ -49,6 +53,9 @@ namespace Orchard.Layouts.Framework.Drivers {
return OnBuildEditor(element, context);
}
protected virtual void OnCreatingDisplay(TElement element, ElementCreatingDisplayShapeContext context) {
}
protected virtual void OnDisplaying(TElement element, ElementDisplayingContext context) {
}

View File

@@ -6,6 +6,7 @@ namespace Orchard.Layouts.Framework.Drivers {
int Priority { get; }
EditorResult BuildEditor(ElementEditorContext context);
EditorResult UpdateEditor(ElementEditorContext context);
void CreatingDisplay(ElementCreatingDisplayShapeContext context);
void Displaying(ElementDisplayingContext context);
void Displayed(ElementDisplayedContext context);
void LayoutSaving(ElementSavingContext context);