Interceptor code structure

I am currently playing around with interceptors in my application and really enjoying the power they give me!.

Just want to run my current structure by people and see if it is the best course of action for my application.

In our old machii system we have various form handling/page security filters…

In coldbox I have moved to interceptions to accommodate the same functionality… I plan to have generic interceptors such as

PageAccessControl
FormValidation

These interceoptors will contain multiple methods which will announce specific interception points

so PageAccessControl may contain DisplayCategoryProducts, DisplayOrderHistory.

This encapsulates all my form validation/access control logic in single files but separating the logic out by interception point.

Does my setup make sense? Or is there a better way of structuring my code.

Thanks very much guys!

Personally,

All that is better handled by their relevant services, this doesn’t mean they can’t be access or injected inside an interceptor, that is how page security works now. With Form Validation you would still want a service, even though you could do this in an interceptor. But by using a combination you could then use the service in the controller and/or the interceptor. Or you could provide multiple services that did different levels of validation, that could be used inside the interceptor. But personally I would use a module just for that, this way you could remove the module and still offer the other forms of validation.

DisplayCategoryProducts, DisplayOrderHistory would be better suited to their relative models and services as well, for example if you need them to be role based then you could do this at the Controller Level or even use AOP on the methods.

Hope that Helps.

This makes perfect sense… more abstraction basically.

I will move my logic into the service and then add the dependencies to my interceptors

Thanks again Andy!

By the way Andy… I had to leave our coldbox development for a number of weeks because of other developments requests superseding it.

That’s you haven’t had so many questions from me recently!

Thanks again!

no problem.