Grid_Basic::executeFormatters PHP Method

executeFormatters() public method

Format field value using appropriate formatters.
public executeFormatters ( string $field, array $column, string $formatter_prefix = 'format_', boolean $silent = false )
$field string field name
$column array column configuration
$formatter_prefix string prefix of formatter methods
$silent boolean don't throw exception if formatter not found
    public function executeFormatters($field, $column, $formatter_prefix = 'format_', $silent = false)
    {
        if (is_object($column['type']) && $column['type'] instanceof Closure) {
            return $this->current_row[$field] = call_user_func($column['type'], $this->current);
        }
        $formatters = explode(',', $column['type']);
        foreach ($formatters as $formatter) {
            if (!$formatter) {
                continue;
            }
            if ($this->hasMethod($m = $formatter_prefix . $formatter)) {
                // formatter method is included in this class
                $this->{$m}($field, $column);
            } elseif (strpos($formatter, '\\') || strpos($formatter, '/')) {
                // add-on support:
                // http://agiletoolkit.org/codepad/gui/grid#codepad_gui_grid_view_example_7_ex
                /** @type Controller_Grid_Format $c */
                $c = $this->getElement($formatter . '_' . $field);
                $c->formatField($field, $column);
            } else {
                if (!$silent) {
                    throw new BaseException('Grid does not know how to format type: ' . $formatter);
                }
            }
        }
    }