Exemplo n.º 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>');
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function render(Field $field, $data, array $options)
 {
     if ('.' !== $field->getPath()) {
         $data = $this->dataExtractor->get($field, $data);
     }
     return $this->twig->render($options['template'], ['data' => $data, 'options' => $options]);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function render(Field $field, $data)
 {
     if ('.' !== $field->getPath()) {
         $data = $this->dataExtractor->get($field, $data);
     }
     return $this->twig->render($field->getOptions()['template'], ['data' => $data]);
 }
 /**
  * {@inheritdoc}
  */
 public function get(Field $field, $data)
 {
     return $this->propertyAccessor->getValue($data, $field->getPath());
 }
 function it_uses_property_accessor_to_extract_the_data(PropertyAccessorInterface $propertyAccessor, Field $field)
 {
     $field->getPath()->willReturn('foo');
     $propertyAccessor->getValue(['foo' => 'bar'], 'foo')->willReturn('Value');
     $this->get($field, ['foo' => 'bar'])->shouldReturn('Value');
 }