Some code refactoring for the various export functions:
1)
I separated out the new function panels_pane_export() from panels_export_display() for some reasons:
- A pane is logically an object on its own, and not part of the display object, so it deserves its own export function, even if we have no UI for exporting panes.
- The code gets easier to grasp and to manage.
- This is a step towards OOP.
- It doesn't break anything.
I called the function panels_pane_export (as panels_var_export) and not panels_export_pane (as panels_export_display), as the former naming is more OO.
2)
I included $display->did, $panel_page->pid and $panel_mini->pid back into the foreach construct. It's simply cleaner to set them in the object and then export them as any other fields.
To make this possible, I had to add the 'pid' field to panels_page_fields() and unset it in panels_page_save(), which is basically a good thing. panels_page_fields is basically a poorman's SchemaAPI, and there is no reason to leave a field out there.
3)
In panels_page_export, I unset $fields['displays'] before entering the foreach construct, instead of doing exception handling within the foreach construct. It's just a bit cleaner.
4)
I corrected the not really consistent indentation, so the output is better structured now.
5)
panels_var_export() used to do the str_replace($output) even if $output = 'array()'. This was unnecessary and bloated the code.
This will break #260278 vice versa, so after you committed either of them, I need to reroll the other.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | panels_export.patch | 6.55 KB | pancho |
Comments
Comment #1
panchoOh I thought the issue number would turn into a link automatically... Now that's the other issue that will interfere with this: #260278: New, consistent save routines
Comment #2
sdboyer commentedCool, great - don't bother to roll the patch until #260278: New, consistent save routines is dealt with, we'll deal with that one first.
Comment #3
panchoOoops, the patch was ready, I just forgot to attach it... Here we go.
edit: Also added another bug fix: when exporting a display without panes, a foreach-warning is thrown. Added another check.
Comment #4
sdboyer commentedSo, it seems like some of the changes here are really pretty superficial - most of what's in the panels_page and mini_panel stuff, in fact. I do, though, see the value in extracting the pane exporter from the display exporter, so I've worked that piece in.
Committed, but like #260278: New, consistent save routines, leaving it CNR to percolate.
Comment #5
sdboyer commentedSo a discussion a few days back indicates that somewhere in this refactoring, an object is being run through var_export, which does bad things in php4. I'm marking this CNW as a reminder to myself to comb back through and figure out where that problem is.
Comment #6
sdboyer commentedThe original refactor was a mess. I need to go through and take a few hours to actually fix this.
Comment #7
simeQueue cleanup, assuming this was sorted out one way or another.