Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created February 29, 2012 09:34
Show Gist options
  • Save michaeltwofish/1939451 to your computer and use it in GitHub Desktop.
Save michaeltwofish/1939451 to your computer and use it in GitHub Desktop.
News::applyFilter('find', function($self, $params, $chain) {
$result = $chain->next($self, $params, $chain);
$function = function($item) {
$item->content = nl2br(htmlspecialchars($item->content, ENT_QUOTES, 'UTF-8'));
$item->date_updated_pretty_date = date('j F Y', strtotime($item->date_updated));
$item->date_updated_pretty_time = date('H:i', strtotime($item->date_updated));
$item->date_created = date('F jS, Y', strtotime($item->date_created));
$item->date_updated = date('F jS, Y', strtotime($item->date_updated));
$item->dealer_groups = explode(';', $item->dealer_groups);
return $item;
}
if ($result) {
if ($result instanceof \lithium\util\Collection) {
$result->map($function);
} else {
$result = $function($result);
}
}
return $result;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment