-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathPopulator.php
32 lines (25 loc) · 1.13 KB
/
Populator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
namespace Civi\Pop;
class Populator {
function __construct($entityStore, $optionStore){
$this->entityStore = $entityStore;
$this->optionStore = $optionStore;
}
function relationshipFields($entity, &$fields){
// if no relationship type has been specified, get one
if(!isset($fields['relationship_type_id'])){
$relationshipType = $this->entityStore->getRandom('RelationshipType');
}else{
$relationshipType = $this->entityStore->getSpecific('RelationshipType', NULL, $fields['relationship_type_id']);
}
$fields['relationship_type_id']=$relationshipType['id'];
$fields['contact_id_a'] = $this->entityStore->getRandom('Contact', array('contact_type' => $relationshipType['contact_type_a']))['id'];
$fields['contact_id_b'] = $this->entityStore->getRandom('Contact', array('contact_type' => $relationshipType['contact_type_b']))['id'];
}
function eventId($entity, &$fields){
// if no relationship type has been specified, get one
if(!isset($fields['event_id'])){
$fields['event_id'] = $this->entityStore->getRandom('Event', array('is_template' => false))['id'];
}
}
}