/// <summary> /// This checks for the parent controller type and validates it, then sets the appropriate properties /// </summary> /// <param name="requestContext"></param> protected override void Initialize(global::System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); //get the extender data stored to access the additional parameters var extenderData = RouteData.GetControllerExtenderParameters(); if (extenderData.Length != 1 && extenderData[0] is string) { throw new LocalizedNotSupportedException("The AdditionalParameters must contain one item as a string representing the tree id"); } _treeId = new Guid(extenderData[0].ToString()); }
/// <summary> /// This checks for the parent controller type and validates it, then sets the appropriate properties /// </summary> /// <param name="requestContext"></param> protected override void Initialize(global::System.Web.Routing.RequestContext requestContext) { base.Initialize(requestContext); var parentContext = RouteData.GetControllerExtenderParentContext(); if (parentContext == null) { throw new NotSupportedException(this.GetType().Name + " cannot be instantiated unless it is created as a Controller Extender"); } var baseType = parentContext.Controller.GetType().BaseType; if (baseType == null || !baseType.Name.StartsWith(typeof(AbstractRevisionalContentEditorController <>).Name)) { throw new NotSupportedException(this.GetType().Name + " cannot be instantiated unless it is created as a Controller Extender for type " + typeof(AbstractRevisionalContentEditorController <>).Name); } ContentController = (dynamic)parentContext.Controller; //now that we have a reference to the parent content controller, assign the ViewBag values which are normally required for creating forms in views ViewBag.ControllerId = UmbracoController.GetControllerId <EditorAttribute>(ContentController.GetType()); }