public function renderBlock(\Twig_Template $template, ColumnInterface $column, $object, $context, $blocks)
{
try {
$value = $this->accessor->getValue($object, $column->getName());
} catch (ExceptionInterface $exception) {
$value = null;
}
$block = 'crudify_field_' . $column->getType();
// check if the block exists
$hasBlock = false;
if (!isset($blocks[$block])) {
$current = $template;
do {
if ($current->hasBlock($block)) {
break;
}
$current = $current->getParent($context);
} while ($current instanceof \Twig_Template);
if ($current instanceof \Twig_Template) {
$hasBlock = true;
}
} else {
$hasBlock = true;
}
if ($hasBlock) {
$context['value'] = $value;
$context['definition'] = $column->getParent()->getParent();
$context['column'] = $column;
$context['object'] = $object;
$result = $template->renderBlock($block, $context, $blocks);
} else {
$result = htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
}
return $result;
}