Skip to content

Instantly share code, notes, and snippets.

@michaeltwofish
Created February 19, 2011 04:29
Show Gist options
  • Save michaeltwofish/834821 to your computer and use it in GitHub Desktop.
Save michaeltwofish/834821 to your computer and use it in GitHub Desktop.
// Create a finder for clusters not linked to 'object'
static::finder('unlinked', function($self, $params, $chain) {
$object = $params['options']['object'];
unset($params['options']['object']);
// @todo Shouldn't make a direct call to getClusters, but should instead
// have a protected array of things that can be linked
$ids = $object->getClusters()->map(function($cluster) {
return $cluster->id;
}, array('collect' => false));
if (count($ids) > 0) {
$params['options']['conditions'] = array(
'id' => array(
'!=' => $ids
)
);
}
return $chain->next($self, $params, $chain);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment