Commit 8e71f8a9 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Pass view object to new blockinstances when available



When creating a new BlockInstance object for a view, pass the view
object to the BlockInstance constructor when we already have it
handy.  This stops the BlockInstance from having to pull the view
out of the database again in its get_view method, and can save
several queries when rendering a view.

Change-Id: I717f154031794afec1ca0d353c1d358f297c5c1e
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 9b48e8c4
......@@ -1196,6 +1196,7 @@ class BlockInstance {
'blocktype' => $this->get('blocktype'),
'title' => $this->get('title'),
'view' => $view->get('id'),
'view_obj' => $view,
'column' => $this->get('column'),
'order' => $this->get('order'),
));
......
......@@ -1390,6 +1390,7 @@ class View {
foreach ($data as $block) {
require_once(get_config('docroot') . 'blocktype/lib.php');
$block->view_obj = $this;
$b = new BlockInstance($block->id, (array)$block);
$this->columns[$block->column]['blockinstances'][] = $b;
}
......@@ -1559,6 +1560,7 @@ class View {
'blocktype' => $values['blocktype'],
'title' => $newtitle,
'view' => $this->get('id'),
'view_obj' => $this,
'column' => $values['column'],
'order' => $values['order'],
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment