Event for updating content type definition

Topics: Troubleshooting, Writing modules
May 20, 2013 at 10:01 AM
Edited May 20, 2013 at 11:00 AM
how can I "detect" the moment when user is creating new content type (not item)? I'd like to do sth like this:
if (ContentTypeDefinition.PartsDefinition.Contains("myPart")) {
I've tried to use ContentHandler, but none of event was called when saving new content type definition.

OK, to close. I handled it.
May 20, 2013 at 1:42 PM
I need another event: removing content type. Is there any event for that?
May 21, 2013 at 10:12 AM
There's no event for that, although it does signal to invalidate a cache. Perhaps you can somehow listen for that signal as the cache does. However, this signal is triggered for other actions as well, so it would still be tricky to determine what the triggered the signal.
May 21, 2013 at 9:40 PM
Ok, maybe there is a workaround: what about overriding route to redirect to my action that handles additional actions and then redirect to stock Orchard action controller. What about it? Where can I find controller for Admin/CotnentType/Edit route?
May 21, 2013 at 11:07 PM
Sure, that could work, although I'm not sure how you would handle the POST requests, but worst case you reimplement the AdminController yourself.
You'll find the controller in Orchard.ContentTypes.
May 22, 2013 at 9:38 AM
Edited May 22, 2013 at 9:39 AM
Since 1.7 you will be able to make use of the new NHibernate-related extension points for plugging into session pipeline. This way you could detect if a record with a given name gets created/updated. Check Orchard.Framework\Data\ISessionInterceptor.cs in the latest code in 1.x branch.
May 22, 2013 at 3:40 PM
Thanks, I will take a look and try both solutions.