Example #1
0
 function it_uses_data_directly_if_dot_is_configured_as_path(\Twig_Environment $twig, Field $field)
 {
     $field->getOptions()->willReturn(['template' => 'foo.html.twig']);
     $field->getPath()->willReturn('.');
     $twig->render('foo.html.twig', ['data' => 'bar'])->willReturn('<html>Bar</html>');
     $this->render($field, 'bar')->shouldReturn('<html>Bar</html>');
 }
Example #2
0
 /**
  * @param Field $field
  * @param $data
  */
 public function renderField(GridView $gridView, Field $field, $data)
 {
     $fieldType = $this->fieldsRegistry->get($field->getType());
     $resolver = new OptionsResolver();
     $fieldType->configureOptions($resolver);
     $options = $resolver->resolve($field->getOptions());
     return $fieldType->render($field, $data, $options);
 }
Example #3
0
 function it_renders_field_with_data_via_appropriate_field_type(GridView $gridView, Field $field, ServiceRegistryInterface $fieldsRegistry, FieldTypeInterface $fieldType)
 {
     $field->getType()->willReturn('string');
     $fieldsRegistry->get('string')->willReturn($fieldType);
     $fieldType->configureOptions(Argument::type(OptionsResolver::class))->will(function ($args) {
         $args[0]->setRequired('foo');
     });
     $field->getOptions()->willReturn(['foo' => 'bar']);
     $fieldType->render($field, 'Value', ['foo' => 'bar'])->willReturn('<strong>Value</strong>');
     $this->renderField($gridView, $field, 'Value')->shouldReturn('<strong>Value</strong>');
 }