Jump to:

5540 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » DataObjectDecorator process order

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

Page: 1
Go to End
Author Topic: 1140 Views
  • tbilyn
    Avatar
    Community Member
    9 Posts

    DataObjectDecorator process order Link to this post

    Hi, I have a question

    if there are a couple of decorators which decorates one class, in what order decorators would be processed?

    Situation like this can occur when you want to add functionality to the class that is already decorated by some module that you use in your program.

    I did not find answer anywhere, so I hope you will help me.

  • tbilyn
    Avatar
    Community Member
    9 Posts

    Re: DataObjectDecorator process order Link to this post

    Hi, Luke

    I am working with subsites module. I need to make uploaded files be available to all subsites or only to one subsite.

    To achive this I decorate class File and add to it field Global (boolean). If it is true, the file will be available to all subsites.

    In subsites module there is function to disable/enable filtering by subsites when geting data using DataObject::get, but it not work for files. There is decorator for class File in Subsites module, but in this decorator disabling/enabling subsite filter does not work (there is no code for that). In my decorator I add augmentSQL function and remove filtering from where statement in the query (this is added by subsite's decorator).

    It works, my decorator processes later than subsites' decorator.

    My team leader do not want to change modules becouse of possible updates, etc.

    It is the first issue. The second is following.

    I want to add possibility for dataobjects or pages be available to all subsites or only to one subsite, as with files. But not to add code to each dataobject or page type I will create, but decorate dataobject(sitetree) class and make this functionality be available to new classes. I want to use decorator to achieve this, as I do with files. For this I need to know order of decorators.

    Can you recommend other approach instead of using decorators? I will be very grateful.

  • purplespider
    Avatar
    Community Member
    81 Posts

    Re: DataObjectDecorator process order Link to this post

    "In subsites module there is function to disable/enable filtering by subsites when geting data using DataObject::get"

    Where can I find this function? It's just what I'm looking for!

    I've got a single DataObject::get call that I wish to use to access Pages from another subsite.

    Thanks

  • purplespider
    Avatar
    Community Member
    81 Posts

    Re: DataObjectDecorator process order Link to this post

    Sorry, found it!

    Subsite::get_from_all_subsites()

    1140 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.