Example formatter function:
function($format, $value) {
return is_numeric($value) ? (integer) $value : false;
}
protected _formatters ( ) : array | ||
return | array | of column types to Closure formatter |
/** * Provide an associative array of Closures to be used as the "formatter" key inside of the * `Database::$_columns` specification. * * @see lithium\data\source\Database::_formatters() */ protected function _formatters() { $self = $this; $datetime = $timestamp = function ($format, $value) use($self) { if ($format && ($time = strtotime($value)) !== false) { $val = date($format, $time); if (!preg_match('/^' . preg_quote($val) . '\\.\\d+$/', $value)) { $value = $val; } } return $self->connection->quote($value); }; return compact('datetime', 'timestamp') + array('boolean' => function ($value) use($self) { return $self->connection->quote($value ? 't' : 'f'); }) + parent::_formatters(); }