Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

DataObjectDecorator vs. Extending a Class

Go to End

3 Posts   1561 Views


Community Member, 114 Posts

6 May 2010 at 4:16am

Why is it preferable to use DataObjectDecorator rather than extending a class? I want to add a 'many_many' to my Member class and it craps out when using DataObjectDecorator, but works fine when I extend the class. What is the difference? Why would I use one or the other?



Forum Moderator, 5523 Posts

6 May 2010 at 10:48pm

You would still point to 'Member' in your Many_Many not the extension specifically. A decorator is useful as you can apply multiple decorators per object and you won't have to rewrite core functionality / queries to use your custom class. DataObjectDecorators 'append' functionality to an existing object which can be a cleaner way to extend the functionality.


Community Member, 114 Posts

7 May 2010 at 6:56am

it actually made more sense in my project to go a different direction on this particular problem, but that is good to know. thanks.