Skip to content

Instantly share code, notes, and snippets.

@gwoo
Created November 24, 2012 22:34
Show Gist options
  • Save gwoo/4141670 to your computer and use it in GitHub Desktop.
Save gwoo/4141670 to your computer and use it in GitHub Desktop.
filter for Media::encode arrays.
Media::applyFilter('encode', function($self, $params, $chain) {
foreach ($params['data'] as $key => $value) {
if ($value instanceof \lithium\data\Collection) {
$params['data'][$key] = array_values($value->to('array'));
}
}
return $chain->next($self, $params, $chain);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment