Custom block that lists blocks from a stack fails on drag-n-drop

Permalink
I'm using 5.7.5.2. I've written a custom block that allows a user to select a stack. In the view of the custom block I'm attempting to iterate through the blocks of the selected stack. This works fine while viewing the block in edit mode or simply adding it. However, if I drag the custom block to a new area, I get an error message. Please see the attached screen shot.

This is how I'm trying to iterate the stack of blocks:

In my block controller:

$stack = Stack::getByID(intval($this->c5stackID));
$a = Area::get($stack, STACKS_AREA_NAME);
$a->disableControls();
$this->set('blocks', $a->getAreaBlocksArray());


In my blocks view:

foreach ($blocks as $b) {
            $b->display();
}


I've dug through the code and I even looked at the code that renders a stack that's built into C5. I know I can check for permissions, etc. but I'm just wondering why I get the error attached. I can't figure it out for the life of me. I see that a method is being called on a null object so I tried what C5 does - almost verbatim but without permissions - and I still get the problem. So I've tried:

$bv = new BlockView($b);
$bv->setAreaObject($a);
$bv->render('view');


Any ideas?

1 Attachment

stephendmalloy