Created
February 19, 2011 04:29
-
-
Save michaeltwofish/834821 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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