Formats a row of data using the given model

Static method only available for single rows, for a convenient way of using on a
rowset, use the class and iterate

@param array $row
@param \MUtil_Model_ModelAbstract $model
@return array The formatted array
549432
public function format($row, $model) {
        foreach ($row as $fieldname=>$value) {
                $row[$fieldname] = $this->_format($fieldname, $row[$fieldname], $model);
        }
        return $row;
    }
872316
public static function convertToArray($row)
    {
        $data = $row instanceof Arrayable ? $row->toArray() : (array) $row;

        foreach ($data as &$value) {
            if (is_object($value) || is_array($value)) {
                $value = self::convertToArray($value);
            }

            unset($value);
        }

        return $data;
    }
801011
public function row( array $row ) {

		$extra_row_count = 0;

		if ( count( $row ) > 0 ) {
			$extra_rows = array_fill( 0, count( $row ), array() );

			foreach( $row as $col => $value ) {

				$value = str_replace( array( "\r\n", "\n" ), ' ', $value );

				$col_width = $this->_widths[ $col ];
				$encoding = function_exists( 'mb_detect_encoding' ) ? mb_detect_encoding( $value, null, true /*strict*/ ) : false;
				$original_val_width = Colors::width( $value, self::isPreColorized( $col ), $encoding );
				if ( $col_width && $original_val_width > $col_width ) {
					$row[ $col ] = \cli\safe_substr( $value, 0, $col_width, true /*is_width*/, $encoding );
					$value = \cli\safe_substr( $value, \cli\safe_strlen( $row[ $col ], $encoding ), null /*length*/, false /*is_width*/, $encoding );
					$i = 0;
					do {
						$extra_value = \cli\safe_substr( $value, 0, $col_width, true /*is_width*/, $encoding );
						$val_width = Colors::width( $extra_value, self::isPreColorized( $col ), $encoding );
						if ( $val_width ) {
							$extra_rows[ $col ][] = $extra_value;
							$value = \cli\safe_substr( $value, \cli\safe_strlen( $extra_value, $encoding ), null /*length*/, false /*is_width*/, $encoding );
							$i++;
							if ( $i > $extra_row_count ) {
								$extra_row_count = $i;
							}
						}
					} while( $value );
				}

			}
		}

		$row = array_map(array($this, 'padColumn'), $row, array_keys($row));
		array_unshift($row, ''); // First border
		array_push($row, ''); // Last border

		$ret = join($this->_characters['border'], $row);
		if ( $extra_row_count ) {
			foreach( $extra_rows as $col => $col_values ) {
				while( count( $col_values ) < $extra_row_count ) {
					$col_values[] = '';
				}
			}

			do {
				$row_values = array();
				$has_more = false;
				foreach( $extra_rows as $col => &$col_values ) {
					$row_values[ $col ] = array_shift( $col_values );
					if ( count( $col_values ) ) {
						$has_more = true;
					}
				}

				$row_values = array_map(array($this, 'padColumn'), $row_values, array_keys($row_values));
				array_unshift($row_values, ''); // First border
				array_push($row_values, ''); // Last border

				$ret .= PHP_EOL . join($this->_characters['border'], $row_values);
			} while( $has_more );
		}
		return $ret;
	}
259144
def format_row(self, row):
        
        res = []
        headers = getattr(self, 'headers', [])
        for column in headers:
            column_name = column['name']
            value = row.get(column_name, '')
            if hasattr(self, "format_%s" % column_name):
                value = getattr(self, "format_%s" % column_name)(value)
            res.append(value)
        return res
207946
public function add($row = array())
    {
        //Argument 1 must be an array or Eden\Collection\Model
        Argument::i()->test(1, 'array', $this->model);

        //if it's an array
        if (is_array($row)) {
            //make it a model
            $model = trim(str_replace('\\', '_', $this->model), '_');
            $row = $this->$model($row);
        }

        //add it now
        $this->list[] = $row;

        return $this;
    }
103735
public function setFromArray(array $row = [])
    {
        parent::setFromArray($row);
        try {
            $data = $this->data ? json_decode($this->data, true) : [];
        } catch (\Exception $e) {
            $data = [];
        }
        $this->data = (new DataObject)->setParams($data);
        return $this;
    }
1233313
protected function renderDataCellContent($row, $data)
    {
        /* @var $am CAuthManager|AuthBehavior */
        $am = Yii::app()->getAuthManager();

        $labelType = $this->active || $am->hasParent($this->itemName, $data['name']) || $am->hasChild(
            $this->itemName,
            $data['name']
        ) ? 'info' : '';

        /* @var $controller AuthItemController */
        $controller = $this->grid->getController();

        echo TbHtml::labelTb(
            $controller->getItemTypeText($data['item']->type),
            array(
                'color' => $labelType,
            )
        );
    }
933848
public function addRow($row)
    {
        if ($row instanceof TableSeparator) {
            $this->rowsCopy[] = $row;

            return parent::addRow($row);
        }

        if (!is_array($row)) {
            throw new \InvalidArgumentException('A row must be an array or a TableSeparator instance.');
        }

        $this->rowsCopy[] = array_values($row);

        return parent::addRow($row);
    }
495070
public function getValue(array $row, array $rows = [])
    {
        if (isset($row[$this->getName()])) {
            $rawValue = $row[$this->getName()];
        } else {
            $rawValue = null;
        }
        // if a callback is set
        $callback = $this->getDisplayCallback();
        if (!is_null($callback)) {
            if (!is_callable($callback)) {
                throw new \Exception('displayCallback is not callable');
            }

            return $callback($rawValue, $row, $rows);
        } else {
            switch ($this->getDisplayFormat()) {
                case static::FORMAT_DATE:
                    $formatParams = $this->getDisplayFormatParams();
                    if (is_null($formatParams)) {
                        $formatParams = 'Y-m-d H:i:s';
                    }
                    if (!is_null($rawValue) && is_object($rawValue) && get_class($rawValue) == 'DateTime') {
                        return $rawValue->format($formatParams);
                    } else {
                        return '';
                    }
                    break;
                case static::FORMAT_TEXT:
                default:
                    if (is_array($rawValue)) {
                        return implode(',', $rawValue);
                    } else {
                        return $rawValue;
                    }
                    break;
            }
        }
    }
158402
public function formatEloquentModel($model)
    {
        $key = Str::singular($model->getTable());

        if (! $model::$snakeAttributes) {
            $key = Str::camel($key);
        }

        return $this->encode([$key => $model->toArray()]);
    }
878917
public function format($row)
    {
        $data = $this->getArray($row);
        $prefix = $this->getHeaderPrefix($data);
        $data = $this->process($data);

        foreach ($data as &$element) {
            if (is_null($element)) {
                $element = $this->csvFormat->getNullValue();
            } else {
                $element = $this->csvFormat->getQuote() . $this->escape($element) . $this->csvFormat->getQuote();
            }
        }

        return $prefix . $this->encode(implode($this->csvFormat->getDelimiter(), $data));
    }
1001502
private function formatRows($response)
    {
        $rows = [];
        foreach ($response['results'] as $result) {
            $columns = $result['columns'];
            $tmpColumns = [];
            foreach ($result['data'] as $dat) {
                $i = 0;
                foreach ($dat['row'] as $row) {
                    $tmpColumns[$i][] = $row;
                    ++$i;
                }
            }
            $y = 0;
            foreach ($columns as $k => $col) {
                if (!empty($tmpColumns)) {
                    $rows[$col] = $tmpColumns[$k];
                    if (is_array($tmpColumns[$k])) {
                        foreach ($tmpColumns[$k] as $i => $el) {
                            if (is_array($el) && isset($el[0])) {
                                $el[0] = 'maybe relationship';
                                if (isset($response['results'][0]['data'][$k])) {
                                    $maybeRel = $response['results'][0]['data'][$k]['rest'][$y];
                                    if (isset($maybeRel['start'])) {
                                        $rows[$col][$i] = $this->getOnlyUsefulEdgeInfoFromRestFormat($maybeRel);
                                    }
                                    if (is_array($maybeRel)) {
                                        $areRels = false;
                                        foreach ($maybeRel as $rel) {
                                            if (isset($rel['start'])) {
                                                $areRels = true;
                                            }
                                        }
                                        if ($areRels) {
                                            $rows[$col][$i] = $this->getUsefulRestEdgeInfoFromCollection($maybeRel);
                                        }
                                    }
                                }

                            }
                        }
                    }
                }
                ++$y;
            }
        }

        return $rows;
    }
984380
public function _prepareArrayRow(\Magento\Framework\DataObject $row)
    {
        $optionExtraAttr = [];
        $optionExtraAttr['option_' . $this->getStatusRenderer()
            ->calcOptionHash($row->getData('status'))]
                         = 'selected="selected"';
        $optionExtraAttr['option_' . $this->getAutomationRenderer()
            ->calcOptionHash($row->getData('automation'))]
                         = 'selected="selected"';
        $row->setData(
            'option_extra_attrs',
            $optionExtraAttr
        );
    }
218952
public function typecastSaveRow(Model $m, $row)
    {
        if (!$row) {
            return $row;
        }

        $result = [];
        foreach ($row as $key => $value) {

            // Look up field object
            $f = $m->hasElement($key);

            // Figure out the name of the destination field
            $field = $key;

            // We have no knowledge of the field, it wasn't defined, so
            // we will leave it as-is.
            if (!$f) {
                $result[$field] = $value;
                continue;
            }

            $value = $this->typecastSaveField($f, $value);

            // store converted value
            $result[$field] = $value;
        }

        return $result;
    }
672041
public static function getRowInstance($row) {
		if (is_array($row)) {
			return new \Aginev\Datagrid\Rows\ArrayRow($row);
		} else if ($row instanceof Model) {
			return new \Aginev\Datagrid\Rows\ModelRow($row);
		} else if ($row instanceof Collection) {
			return new \Aginev\Datagrid\Rows\CollectionRow($row);
		} else if (is_object($row)) {
			return new \Aginev\Datagrid\Rows\ObjectRow($row);
		}

		throw new CellException('Unsupported data!');
	}
127272
private function processImportRow(&$row)
    {
        // Get the model to represent this row.
        $model = $this->lookupModel($row);

        // Assign values to the model.
        foreach ($row as $key => $value) {
            if (empty($model->getKey()) || $model->$key !== $value) {
                $model->$key = $value;
            }
        }

        $model->save();

        $this->progress_bar->advance();
    }
129515
public function toHtml(array $row)
    {
        if ($this->getLabel() == '') {
            throw new \InvalidArgumentException(
                'A label is required for this action type, please call $action->setLabel()!'
            );
        }

        $label = $this->getLabel();
        if ($label instanceof AbstractColumn) {
            $label = $row[$label->getUniqueId()];
        }

        return '<a '.$this->getAttributesString($row).'>'.$label.'</a>';
    }