The Redirect service doesn't currently expose any events.
A Registered event should be simple to add, though I'd be wary of doing too much work in your event handler because you could make it very expensive to rename a page with many descendants.
A Deleted event would add some overhead because it would need to fetch the details from the database. That's not a big deal when deleting a single redirect from the dashboard, though.
The awkward part would be if you need to know about redirects being deleted when content is deleted. Although the service has a DeleteContentRedirectUrls method, it's not used when content is being deleted. The ContentService deals with deleting the affected redirects itself.
So I have been digging a little through the deleting of content in the code. Design wise it seems incorrect that the RedirectUrlService doesn't take care of handling deletions. For example if we were to make a cache decorator around the redirects, we wouldn't be able to do that - which is quite annoying. Not that i am trying to achieve that right now.
So I assume it is done by a SQL GetDeleteClauses() (DocumentRepository.cs, line 188) because it should be easier to read and everything concerning the specific piece of content would be deleted.
I agree with you that it is going to be difficult to raise an event when multiple redirects are being deleted.
Do you know whether this part of the code is something that is being refactored for v9?
Redirect Service events
Hi Umbraco Forum.
Is there any events for the Redirect service? So we can subscribe to for example Register/Delete?
Regards Malthe
The Redirect service doesn't currently expose any events.
A
Registered
event should be simple to add, though I'd be wary of doing too much work in your event handler because you could make it very expensive to rename a page with many descendants.A
Deleted
event would add some overhead because it would need to fetch the details from the database. That's not a big deal when deleting a single redirect from the dashboard, though.The awkward part would be if you need to know about redirects being deleted when content is deleted. Although the service has a
DeleteContentRedirectUrls
method, it's not used when content is being deleted. TheContentService
deals with deleting the affected redirects itself.Hi Steve.
Thank you for your very awesome answer. :-)
So I have been digging a little through the deleting of content in the code. Design wise it seems incorrect that the RedirectUrlService doesn't take care of handling deletions. For example if we were to make a cache decorator around the redirects, we wouldn't be able to do that - which is quite annoying. Not that i am trying to achieve that right now.
So I assume it is done by a SQL GetDeleteClauses() (DocumentRepository.cs, line 188) because it should be easier to read and everything concerning the specific piece of content would be deleted.
I agree with you that it is going to be difficult to raise an event when multiple redirects are being deleted.
Do you know whether this part of the code is something that is being refactored for v9?
is working on a reply...