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;
 }
 function it_should_indicate_a_column_with_some_field_should_exist(ColumnInterface $first, ColumnInterface $second)
 {
     $first->getField()->willReturn('some_field');
     $second->getField()->willReturn('another_field');
     $first->setParent($this)->willReturn();
     $second->setParent($this)->willReturn();
     $this->addColumn($first);
     $this->addColumn($second);
     $this->hasColumnWithField('another_field')->shouldReturn(true);
     $this->hasColumnWithField('nonexistant_field')->shouldReturn(false);
 }
 /**
  * @param ColumnInterface $column
  * @param string          $direction
  */
 public function setDefaultSort(ColumnInterface $column, $direction = self::SORT_ASC)
 {
     $this->defaultSortColumn = $column;
     $this->defaultSortDirection = $direction;
     $column->setParent($this);
 }