CRM_Core_CodeGen_GenerateData
in package
Table of Contents
Constants
- ADD_TO_DB = \TRUE
- Constants
- DATA_FILENAME = "sample_data.xml"
- HOME = 1
- HOUSEHOLD_PERCENT = 10
- INDIVIDUAL_PERCENT = 80
- MAIN = 3
- NUM_ACTIVITY = 150
- NUM_CONTACT = 200
- NUM_DOMAIN = 1
- NUM_INDIVIDUAL_PER_HOUSEHOLD = 4
- ORGANIZATION_PERCENT = 10
- OTHER = 4
- WORK = 2
Properties
- $contact : array<string|int, mixed>
- store contact id's
- $contactType : mixed
- $deceasedContactIds : mixed
- $domain : array<string|int, mixed>
- store domain id's
- $gender : mixed
- $groupMembershipStatus : mixed
- $Household : mixed
- $householdIndividual : mixed
- $householdName : mixed
- $Individual : mixed
- $location : array<string|int, mixed>
- for automatic management of is_primary field
- $numHousehold : mixed
- $numIndividual : mixed
- $numOrganization : mixed
- $numStrictIndividual : mixed
- $Organization : mixed
- $phoneType : mixed
- $preferredCommunicationMethod : array<string|int, mixed>
- enum's from database
- $prefix : array<string|int, mixed>
- customizable enums (foreign keys)
- $relTypes : mixed
- $sampleData : array<string|int, mixed>
- sample data in xml format
- $seed : int
- $startCid : array<string|int, mixed>
- private vars
- $stateMap : mixed
- $states : mixed
- $strictIndividual : array<string|int, mixed>
- stores the strict individual id and household id to individual id mapping
- $subscriptionHistoryMethod : mixed
- $suffix : array<string|int, mixed>
- $time : mixed
Methods
- __construct() : mixed
- Class constructor
- generate() : mixed
- Public wrapper for calling private "add" functions Provides user feedback
- generateAll() : mixed
- Create a full, standard set of random data.
- getLatLong() : array<string|int, mixed>
- getZipCodeInfo() : array<string|int, mixed>
- initID() : mixed
- this function creates arrays for the following
- randomName() : string
- repairDate() : string
- write() : mixed
- Write a log message.
- getCivicrmDir() : string
- _addAddress() : array<string|int, mixed>
- Create an address for a contact
- _addDAO() : mixed
- Add core DAO object
- _addEmail() : array<string|int, mixed>
- Add an email for a contact
- _addPhone() : array<string|int, mixed>
- Add a phone number for a contact
- _addWebsite() : array<string|int, mixed>
- Add a website based on organization name Using common naming patterns
- _individualEmail() : string
- Create an email address based on a person's name Using common naming patterns
- _insert() : mixed
- Call dao insert method unless we are doing a dry run
- _query() : CRM_Core_DAO
- Execute a query unless we are doing a dry run Note: this wrapper should not be used for SELECT queries
- _update() : mixed
- Call dao update method unless we are doing a dry run
- addAccountingEntries() : mixed
- addACL() : void
- This method sets up a basic ACL.
- addActivity() : void
- This method populates the civicrm_activity_history table
- addContact() : mixed
- This method adds data to the contact table
- addContribution() : mixed
- addContributionLineItem() : mixed
- addDomain() : mixed
- This method adds NUM_DOMAIN domains and then adds NUM_REVISION revisions for each domain with the latest revision being the last one.
- addEntityTag() : mixed
- This method populates the civicrm_entity_tag table
- addEvent() : mixed
- addFinancialItem() : mixed
- addGroup() : mixed
- This method populates the civicrm_group_contact table
- addHousehold() : mixed
- This method adds household's data to the contact table
- addIndividual() : mixed
- addIndividual()
- addLineItemParticipants() : mixed
- addMembership() : mixed
- addMembershipLog() : mixed
- addMembershipPayment() : mixed
- addMembershipType() : mixed
- addNote() : mixed
- This method populates the civicrm_note table
- addOrganization() : mixed
- This method adds organization data to the contact table
- addParticipant() : mixed
- addParticipantPayment() : mixed
- addPCP() : mixed
- addPledge() : mixed
- addPledgePayment() : mixed
- addRelationship() : mixed
- This method adds data to the contact_relationship table
- addSoftContribution() : mixed
- getContactType() : string
- Fetch contact type based on stored mapping
- isPrimary() : int
- Automatically manage the is_primary field by tracking which contacts have each item
- probability() : int
- randomChar() : string
- randomDate() : string
- Generate a random date.
- randomIndex() : mixed
- randomInt() : int
- Random number generator.
- randomItem() : mixed
- Get a random item from the sample data or any other array
- randomKeyValue() : array<string|int, mixed>
- randomString() : string
- Get a randomly generated string.
- shuffle() : mixed
Constants
ADD_TO_DB
Constants
public
mixed
ADD_TO_DB
= \TRUE
DATA_FILENAME
public
mixed
DATA_FILENAME
= "sample_data.xml"
HOME
public
mixed
HOME
= 1
HOUSEHOLD_PERCENT
public
mixed
HOUSEHOLD_PERCENT
= 10
INDIVIDUAL_PERCENT
public
mixed
INDIVIDUAL_PERCENT
= 80
MAIN
public
mixed
MAIN
= 3
NUM_ACTIVITY
public
mixed
NUM_ACTIVITY
= 150
NUM_CONTACT
public
mixed
NUM_CONTACT
= 200
NUM_DOMAIN
public
mixed
NUM_DOMAIN
= 1
NUM_INDIVIDUAL_PER_HOUSEHOLD
public
mixed
NUM_INDIVIDUAL_PER_HOUSEHOLD
= 4
ORGANIZATION_PERCENT
public
mixed
ORGANIZATION_PERCENT
= 10
OTHER
public
mixed
OTHER
= 4
WORK
public
mixed
WORK
= 2
Properties
$contact
store contact id's
private
array<string|int, mixed>
$contact
= []
$contactType
private
mixed
$contactType
= ['Individual', 'Household', 'Organization']
$deceasedContactIds
private
mixed
$deceasedContactIds
= []
$domain
store domain id's
private
array<string|int, mixed>
$domain
= []
$gender
private
mixed
$gender
= [1 => 'female', 2 => 'male']
$groupMembershipStatus
private
mixed
$groupMembershipStatus
= ['Added', 'Removed', 'Pending']
$Household
private
mixed
$Household
= []
$householdIndividual
private
mixed
$householdIndividual
= []
$householdName
private
mixed
$householdName
= []
$Individual
private
mixed
$Individual
= []
$location
for automatic management of is_primary field
private
array<string|int, mixed>
$location
= ['Email' => [], 'Phone' => [], 'Address' => []]
$numHousehold
private
mixed
$numHousehold
= 0
$numIndividual
private
mixed
$numIndividual
= 0
$numOrganization
private
mixed
$numOrganization
= 0
$numStrictIndividual
private
mixed
$numStrictIndividual
= 0
$Organization
private
mixed
$Organization
= []
$phoneType
private
mixed
$phoneType
= ['1', '2', '3', '4']
$preferredCommunicationMethod
enum's from database
private
array<string|int, mixed>
$preferredCommunicationMethod
= ['1', '2', '3', '4', '5']
$prefix
customizable enums (foreign keys)
private
array<string|int, mixed>
$prefix
= [
// Female
1 => [1 => 'Mrs.', 2 => 'Ms.', 4 => 'Dr.'],
// Male
2 => [3 => 'Mr.', 4 => 'Dr.'],
]
$relTypes
private
mixed
$relTypes
$sampleData
sample data in xml format
private
array<string|int, mixed>
$sampleData
= []
$seed
private
int
$seed
$startCid
private vars
private
array<string|int, mixed>
$startCid
$stateMap
private
mixed
$stateMap
= []
$states
private
mixed
$states
= []
$strictIndividual
stores the strict individual id and household id to individual id mapping
private
array<string|int, mixed>
$strictIndividual
= []
$subscriptionHistoryMethod
private
mixed
$subscriptionHistoryMethod
= ['Admin', 'Email']
$suffix
private
array<string|int, mixed>
$suffix
= [1 => 'Jr.', 2 => 'Sr.', 3 => 'II', 4 => 'III']
$time
private
mixed
$time
Methods
__construct()
Class constructor
public
__construct(string|int $seed, int $time) : mixed
Parameters
- $seed : string|int
-
Some scalar value used as the starting point for random-number generation.
- $time : int
-
A timestamp; some facsimile of "now".
generate()
Public wrapper for calling private "add" functions Provides user feedback
public
generate(mixed $itemName) : mixed
Parameters
- $itemName : mixed
generateAll()
Create a full, standard set of random data.
public
generateAll() : mixed
getLatLong()
public
static getLatLong(mixed $zipCode) : array<string|int, mixed>
Parameters
- $zipCode : mixed
Return values
array<string|int, mixed>getZipCodeInfo()
public
getZipCodeInfo() : array<string|int, mixed>
Return values
array<string|int, mixed>initID()
this function creates arrays for the following
public
initID() : mixed
domain id contact id contact_location id contact_contact_location id contact_email uuid contact_phone_uuid contact_instant_message uuid contact_relationship uuid contact_task uuid contact_note uuid
randomName()
public
randomName() : string
Return values
stringrepairDate()
public
static repairDate(mixed $date) : string
Parameters
- $date : mixed
Return values
stringwrite()
Write a log message.
public
write(string $message) : mixed
Parameters
- $message : string
getCivicrmDir()
protected
static getCivicrmDir() : string
Return values
string_addAddress()
Create an address for a contact
private
_addAddress(int $cid[, int $masterContactId = NULL ]) : array<string|int, mixed>
Parameters
- $cid : int
-
contact id
- $masterContactId : int = NULL
-
set if this is a shared address
Return values
array<string|int, mixed>_addDAO()
Add core DAO object
private
_addDAO(mixed $type, mixed $params) : mixed
Parameters
- $type : mixed
- $params : mixed
_addEmail()
Add an email for a contact
private
_addEmail(int $cid, mixed $email, mixed $locationType) : array<string|int, mixed>
Parameters
- $cid : int
-
contact id
- $email : mixed
- $locationType : mixed
Return values
array<string|int, mixed>_addPhone()
Add a phone number for a contact
private
_addPhone(int $cid) : array<string|int, mixed>
Parameters
- $cid : int
-
contact id
Return values
array<string|int, mixed>_addWebsite()
Add a website based on organization name Using common naming patterns
private
_addWebsite(int $cid, string $name) : array<string|int, mixed>
Parameters
- $cid : int
-
contact id
- $name : string
-
contact name
Return values
array<string|int, mixed>_individualEmail()
Create an email address based on a person's name Using common naming patterns
private
_individualEmail(CRM_Contact_DAO_Contact $contact[, string $domain = NULL ]) : string
Parameters
- $contact : CRM_Contact_DAO_Contact
-
individual contact record
- $domain : string = NULL
-
supply a domain (i.e. for a work address)
Return values
string_insert()
Call dao insert method unless we are doing a dry run
private
_insert(mixed &$dao) : mixed
Parameters
- $dao : mixed
_query()
Execute a query unless we are doing a dry run Note: this wrapper should not be used for SELECT queries
private
_query(mixed $query[, array<string|int, mixed> $params = [] ]) : CRM_Core_DAO
Parameters
- $query : mixed
- $params : array<string|int, mixed> = []
Return values
CRM_Core_DAO_update()
Call dao update method unless we are doing a dry run
private
_update(mixed &$dao) : mixed
Parameters
- $dao : mixed
addAccountingEntries()
private
addAccountingEntries() : mixed
addACL()
This method sets up a basic ACL.
private
addACL() : void
It allows the members of the advisory group to edit the Summer volunteers group.
Tags
addActivity()
This method populates the civicrm_activity_history table
private
addActivity() : void
Tags
addContact()
This method adds data to the contact table
private
addContact() : mixed
id - from $contact contact_type 'Individual' 'Household' 'Organization' preferred_communication (random 1 to 3)
addContribution()
private
addContribution() : mixed
addContributionLineItem()
private
addContributionLineItem() : mixed
addDomain()
This method adds NUM_DOMAIN domains and then adds NUM_REVISION revisions for each domain with the latest revision being the last one.
private
addDomain() : mixed
.
addEntityTag()
This method populates the civicrm_entity_tag table
private
addEntityTag() : mixed
addEvent()
private
addEvent() : mixed
addFinancialItem()
private
addFinancialItem(mixed $result, null $financialAccountId) : mixed
Parameters
- $result : mixed
- $financialAccountId : null
addGroup()
This method populates the civicrm_group_contact table
private
addGroup() : mixed
Tags
addHousehold()
This method adds household's data to the contact table
private
addHousehold() : mixed
The following fields are generated and added.
contact_uuid - household_individual contact_rid - latest one household_name 'household $contact_uuid primary contact $primary_contact_uuid' nick_name 'nick $contact_uuid' primary_contact_uuid = $household_individual[$contact_uuid][0];
addIndividual()
addIndividual()
private
addIndividual() : mixed
This method adds individual's data to the contact table
The following fields are generated and added.
contact_uuid - individual contact_rid - latest one first_name 'First Name $contact_uuid' middle_name 'Middle Name $contact_uuid' last_name 'Last Name $contact_uuid' job_title 'Job Title $contact_uuid'
addLineItemParticipants()
private
addLineItemParticipants() : mixed
addMembership()
private
addMembership() : mixed
addMembershipLog()
private
addMembershipLog() : mixed
addMembershipPayment()
private
addMembershipPayment() : mixed
addMembershipType()
private
addMembershipType() : mixed
addNote()
This method populates the civicrm_note table
private
addNote() : mixed
addOrganization()
This method adds organization data to the contact table
private
addOrganization() : mixed
The following fields are generated and added.
contact_uuid - organization contact_rid - latest one organization_name 'organization $contact_uuid' legal_name 'legal $contact_uuid' nick_name 'nick $contact_uuid' sic_code 'sic $contact_uuid' primary_contact_id - random individual contact uuid
addParticipant()
private
addParticipant() : mixed
addParticipantPayment()
private
addParticipantPayment() : mixed
addPCP()
private
addPCP() : mixed
addPledge()
private
addPledge() : mixed
addPledgePayment()
private
addPledgePayment() : mixed
addRelationship()
This method adds data to the contact_relationship table
private
addRelationship() : mixed
addSoftContribution()
private
addSoftContribution() : mixed
getContactType()
Fetch contact type based on stored mapping
private
getContactType(mixed $id) : string
Parameters
- $id : mixed
Return values
string —$type
isPrimary()
Automatically manage the is_primary field by tracking which contacts have each item
private
isPrimary(mixed $cid, mixed $type) : int
Parameters
- $cid : mixed
- $type : mixed
Return values
intprobability()
private
probability(mixed $chance) : int
Parameters
- $chance : mixed
Return values
intrandomChar()
private
randomChar() : string
Return values
stringrandomDate()
Generate a random date.
private
randomDate([int $startDate = 0 ][, int $endDate = 0 ]) : string
If both $startDate and $endDate are defined generate date between them.
If only startDate is specified then date generated is between startDate + 1 year.
if only endDate is specified then date generated is between endDate - 1 year.
if none are specified - date is between today - 1year and today
Parameters
- $startDate : int = 0
-
Start Date in Unix timestamp
- $endDate : int = 0
-
End Date in Unix timestamp
Tags
Return values
string —randomly generated date in the format "Ymd"
randomIndex()
private
randomIndex(mixed $items) : mixed
Parameters
- $items : mixed
randomInt()
Random number generator.
private
randomInt(int $min, int $max) : int
All other random() functions should derive from this.
This is very weak RNG. The goal is to provide a reproducible sequence of random-ish values for generating dummy-data.
Parameters
- $min : int
- $max : int
Return values
intrandomItem()
Get a random item from the sample data or any other array
private
randomItem(array<string|int, mixed>|string $items) : mixed
Parameters
- $items : array<string|int, mixed>|string
-
if string, used as key for sample data, if array, used as data source
Tags
Return values
mixed —(element from array)
randomKeyValue()
private
randomKeyValue(mixed $items) : array<string|int, mixed>
Parameters
- $items : mixed
Return values
array<string|int, mixed>randomString()
Get a randomly generated string.
private
randomString([int $size = 32 ]) : string
Parameters
- $size : int = 32
Return values
stringshuffle()
private
shuffle(mixed $array) : mixed
Parameters
- $array : mixed