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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

DataObjectDecorator process order


Go to End


4 Posts   1758 Views

Avatar
tbilyn

Community Member, 9 Posts

11 August 2010 at 2:01am

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.

Avatar
tbilyn

Community Member, 9 Posts

11 August 2010 at 7:19pm

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.

Avatar
purplespider

Community Member, 89 Posts

19 January 2011 at 2:08am

"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

Avatar
purplespider

Community Member, 89 Posts

19 January 2011 at 2:11am

Sorry, found it!

Subsite::get_from_all_subsites()