Example #1
0
 /**
  * @param array $params
  * @param array $data
  * @param array $expected
  *
  * @dataProvider valueDataProvider
  */
 public function testGetRawValue(array $params, array $data, array $expected)
 {
     $this->property->init(PropertyConfiguration::create($params));
     $record = new ResultRecord($data);
     $template = $this->getMock('Twig_TemplateInterface');
     $this->twig->expects($this->once())->method('loadTemplate')->with($this->equalTo(LinkProperty::TEMPLATE))->will($this->returnValue($template));
     if (!empty($data[LinkProperty::ROUTE_KEY])) {
         $this->router->expects($this->once())->method('generate')->will($this->returnValue($data[LinkProperty::ROUTE_KEY]));
     }
     $template->expects($this->once())->method('render')->with($this->equalTo($expected));
     $this->property->getRawValue($record);
 }
 /**
  * {@inheritDoc}
  */
 public function visitMetadata(DatagridConfiguration $config, MetadataObject $data)
 {
     // get only columns here because columns will be represented on frontend
     $columns = $config->offsetGetOr(Configuration::COLUMNS_KEY, []);
     $propertiesMetadata = [];
     foreach ($columns as $name => $fieldConfig) {
         $fieldConfig = PropertyConfiguration::createNamed($name, $fieldConfig);
         $metadata = $this->getPropertyObject($fieldConfig)->getMetadata();
         // translate label on backend
         $metadata['label'] = $this->translator->trans($metadata['label']);
         $propertiesMetadata[] = $metadata;
     }
     $data->offsetAddToArray('columns', $propertiesMetadata);
 }