/**
  * {@inheritdoc}
  */
 public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view)
 {
     $value = array();
     $values = $view->getValue();
     if (($emptyValue = $column->getOption('empty_value')) !== null) {
         $values = $this->populateValues($values, $emptyValue);
     }
     $glue = $column->getOption('value_glue');
     $format = $column->getOption('value_format');
     foreach ($values as $val) {
         $objectValue = null;
         if (isset($glue) && !isset($format)) {
             $objectValue = implode($glue, $val);
         }
         if (isset($format)) {
             if (isset($glue)) {
                 $formatedValues = array();
                 foreach ($val as $fieldValue) {
                     $formatedValues[] = sprintf($format, $fieldValue);
                 }
                 $objectValue = implode($glue, $formatedValues);
             } else {
                 $objectValue = vsprintf($format, $val);
             }
         }
         $value[] = $objectValue;
     }
     $value = implode($column->getOption('glue_multiple'), $value);
     $view->setValue($value);
 }
 function it_passes_width_as_view_attribute(CellViewInterface $cellView)
 {
     $this->initOptions();
     $this->setOptions(array('width' => 100));
     $cellView->setAttribute('width', 100)->shouldBeCalled();
     $this->buildCellView($cellView);
 }
 /**
  * @param \FSi\Component\DataGrid\Column\CellViewInterface $view
  * @param \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath
  * @return object
  */
 private function getMostNestedObject(CellViewInterface $view, PropertyPathInterface $propertyPath)
 {
     if ($propertyPath->getLength() > 1) {
         return $this->propertyAccessor->getValue($view->getSource(), $propertyPath->getParent()->__toString());
     } else {
         return $view->getSource();
     }
 }
Ejemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view)
 {
     if (!$column->getOption('editable')) {
         return;
     }
     $data = $view->getSource();
     $index = $view->getAttribute('row');
     $form = $this->createForm($column, $index, $data);
     $view->setAttribute('form', $form->createView());
 }
Ejemplo n.º 5
0
 /**
  * @param \FSi\Component\DataGrid\Column\ColumnTypeInterface $column
  * @param \FSi\Component\DataGrid\Column\CellViewInterface $view
  */
 function it_passes_attributes_to_cell_view($column, $view)
 {
     $column->getOption('cell_attr')->willReturn(array('cell attributes'));
     $view->setAttribute('cell_attr', array('cell attributes'))->shouldBeCalled();
     $column->getOption('container_attr')->willReturn(array('container attributes'));
     $view->setAttribute('container_attr', array('container attributes'))->shouldBeCalled();
     $column->getOption('value_attr')->willReturn(array('value attributes'));
     $view->setAttribute('value_attr', array('value attributes'))->shouldBeCalled();
     $this->buildCellView($column, $view);
 }
 /**
  * {@inheritdoc}
  */
 public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view)
 {
     $this->validateEmptyValueOption($column);
     $value = $this->populateValue($view->getValue(), $column->getOption('empty_value'));
     $glue = $column->getOption('value_glue');
     $format = $column->getOption('value_format');
     $value = $this->formatValue($value, $format, $glue);
     if (!isset($glue, $format) && is_array($value)) {
         throw new \InvalidArgumentException(sprintf('At least one of "format" or "glue" option is missing in column: "%s".', $column->getName()));
     }
     $view->setValue($value);
 }
 function it_sets_translatable_and_not_translated_to_true_when_column_has_not_translated_nested_translatable_property_in_field_mapping(ColumnTypeInterface $column, CellViewInterface $view, ClassMetadata $translatableMetadata)
 {
     $column->getOption('field_mapping')->willReturn(array('nested_object.translatable_property'));
     $nested_object = (object) array('translatable_property' => 'value', 'non_translatable_property' => 'value', 'locale' => 'de');
     $data = (object) array('nested_object' => $nested_object);
     $view->getSource()->willReturn($data);
     $translatableMetadata->hasTranslatableProperties()->willReturn(true);
     $translatableMetadata->getTranslatableProperties()->willReturn(array('translations' => array('translatable_property' => 'translation_property')));
     $translatableMetadata->localeProperty = 'locale';
     $view->setAttribute('translatable', true)->shouldBeCalled();
     $view->setAttribute('not_translated', true)->shouldBeCalled();
     $this->buildCellView($column, $view);
 }
 /**
  * {@inheritdoc}
  */
 public function buildCellView(CellViewInterface $view)
 {
     $view->setAttribute('width', $this->getOption('width'));
 }
Ejemplo n.º 9
0
 /**
  * {@inheritdoc}
  */
 public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view)
 {
     $view->setAttribute('cell_attr', $column->getOption('cell_attr'));
     $view->setAttribute('container_attr', $column->getOption('container_attr'));
     $view->setAttribute('value_attr', $column->getOption('value_attr'));
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function buildCellView(CellViewInterface $view)
 {
     $view->setAttribute('datagrid_name', $this->getDataGrid()->getName());
 }
 /**
  * {@inheritDoc}
  */
 public function buildCellView(ColumnTypeInterface $column, CellViewInterface $view)
 {
     $view->setAttribute('translation_domain', $column->getOption('translation_domain'));
 }
 /**
  * @param CellViewInterface $view
  * @param $action
  * @param $content
  * @param array $urlAttrs
  * @param array $fieldMappingValues
  * @return string
  */
 public function datagridColumnActionCellActionWidget(CellViewInterface $view, $action, $content, $urlAttrs = array(), $fieldMappingValues = array())
 {
     $dataGridView = $view->getDataGridView();
     $blockNames = array('datagrid_' . $dataGridView->getName() . '_column_type_action_cell_action_' . $action, 'datagrid_column_type_action_cell_action_' . $action, 'datagrid_' . $dataGridView->getName() . '_column_type_action_cell_action', 'datagrid_column_type_action_cell_action');
     $context = array('content' => $content, 'attr' => $urlAttrs, 'translation_domain' => $view->getAttribute('translation_domain'), 'field_mapping_values' => $fieldMappingValues);
     return $this->renderTheme($dataGridView, $context, $blockNames);
 }
Ejemplo n.º 13
0
 /**
  * {@inheritdoc}
  */
 public function buildCellView(CellViewInterface $view)
 {
     foreach ($this->getViewAttributes() as $attrName => $attrValue) {
         $view->setAttribute($attrName, $attrValue);
     }
 }