Skip to content

Instantly share code, notes, and snippets.

@sdboyer
Forked from EclipseGc/gist:5823702
Last active December 18, 2015 18:09
Show Gist options
  • Save sdboyer/5823704 to your computer and use it in GitHub Desktop.
Save sdboyer/5823704 to your computer and use it in GitHub Desktop.
<?php
protected function renderBlocks(Request $request, BoundDisplayInterface $display) {
$blockFragments = array();
foreach ($display->getAllOuterBlockConfig() as $id => $config) {
$block = $display->getBlock($id);
if ($block instanceof SystemMainBlock) {
$block->setControllerClosure($request->attributes->get('_content_closure'));
}
foreach ($block->getContextDefinitions() as $slot => $context_info) {
if ($config['context'][$slot]['type'] == 'static') {
$data = typed_data_blah_blah_load($config[$slot]['address']);
}
else if ($config['context'][$slot]['type'] == 'argument') {
$data = $request->attributes->get($config[$slot]['address']);
}
else if ($config['context'][$slot]['type'] == 'derived') {
$base = $request->attributes->get($config[$slot]['request_address']);
$data = typed_data_blah_blah_load_from_thinger($base, $config[$slot]['typed_data_crazypants']);
}
$block->setContextValue($slot, $data);
}
$munged_request = clone $request;
// @todo muck with the Request here to get it to where we need
$blockFragments[$id] = $this->renderingStrategies[$config['strategy']]->render($block, $munged_request);
}
return $blockFragments;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment