function party_acquire in Party 7
Acquire or create a party based off conditions.
Parameters
array $values: An array of party fields to match on. Keys are the field and values are the expected values. If empty, we will use the given behavior.
array $context: An array of contextual information. If the 'class' key is set, we'll attempt to use the specified class. Otherwise we fall back to the system default in the 'party_acquire_default_class' variable.
string $method: Optionally pass a variable to be filled with the acquisition method.
Return value
Party|FALSE The acquired or newly created party or FALSE on a failure.
3 calls to party_acquire()
- PartyAcquisitionTestCase::testPartyAcquisition in tests/
party_acquisition.test - Test Acquisition on Party Entities.
- party_user_party_acquisition_post_acquisition in modules/
party_user/ party_user.party_acquisition.inc - Implements hook_party_acquisition_post_acquisition().
- party_user_user_insert in modules/
party_user/ party_user.module - Implements hook_user_insert().
File
- ./
party.module, line 1725 - Provides a generic CRM party entity.
Code
function party_acquire(array $values, $context = array(), &$method = '') {
// Figure out which class to use.
$class = isset($context['class']) ? $context['class'] : variable_get('party_acquire_default_class', 'PartyAcquisition');
// Check this is a valid acquisition class.
if (!class_exists($class)) {
throw new Exception(t('Party acquisition class %class cannot be found.', array(
'%class' => $class,
)));
}
$acquisition = new $class();
if (!$acquisition instanceof PartyAcquisitionInterface) {
throw new Exception(t('Class %class is not a valid acquisition class.', array(
'%class' => $class,
)));
}
// Pass onto the acquire method.
return $acquisition
->acquire($values, $context, $method);
}