Jump to:

22975 Posts in 11620 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » DataObjectDecorator vs. Extending a Class

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

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

Page: 1
Go to End
Author Topic: 1096 Views
  • ttyl
    Avatar
    Community Member
    114 Posts

    DataObjectDecorator vs. Extending a Class Link to this post

    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?

    thanks.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: DataObjectDecorator vs. Extending a Class Link to this post

    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.

  • ttyl
    Avatar
    Community Member
    114 Posts

    Re: DataObjectDecorator vs. Extending a Class Link to this post

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

    1096 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.