本文整理汇总了PHP中Phone::SetAsPrimary方法的典型用法代码示例。如果您正苦于以下问题:PHP Phone::SetAsPrimary方法的具体用法?PHP Phone::SetAsPrimary怎么用?PHP Phone::SetAsPrimary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phone
的用法示例。
在下文中一共展示了Phone::SetAsPrimary方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UpdateAddressInformation
/**
* Given a home (and optional mailing) address validator (which is unlinked from any db entry), go ahead and make updates
* to this person record accordingly.
*
* If this person is part of multiple households, it will throw an error.
*
* If this person is part of one household, it will update the information for the household.
*
* If this person is not part of any houseold, it will create one for him/her.
*
* @param AddressValidator $objHomeAddressValidator
* @param AddressValidator $objMailingAddressValidator optional
* @param string $strHomePhone optional
*/
public function UpdateAddressInformation(AddressValidator $objHomeAddressValidator, AddressValidator $objMailingAddressValidator = null, $strHomePhone = null)
{
$objHouseholdArray = array();
foreach ($this->GetHouseholdParticipationArray() as $objHouseholdParticipation) {
$objHouseholdArray[] = $objHouseholdParticipation->Household;
}
// Figure Out Household Information
if (count($objHouseholdArray) > 1) {
throw new QCallerException('Cannot call UpdateAddressInformation on a person who is part of multiple households: ' . $this->intId);
}
if (count($objHouseholdArray)) {
$objHousehold = $objHouseholdArray[0];
} else {
$objHousehold = Household::CreateHousehold($this);
}
// Home Address
$objHomeAddress = $objHousehold->GetCurrentAddress();
$objAddress = $objHomeAddressValidator->CreateAddressRecord();
// Are we using the existing Household CurrentAddress record?
if ($objHomeAddress && $objHomeAddress->IsEqualTo($objAddress)) {
// Yes -- so all we're handling is the phones
$objHomePhoneArray = $objHomeAddress->GetPhoneArray();
// Are we setting a home phone?
if ($strHomePhone) {
// Try and find the phone within the array
foreach ($objHomePhoneArray as $objPhone) {
$blnFound = false;
if ($objPhone->Number == $strHomePhone) {
$objPhone->SetAsPrimary(null, $objHomeAddress);
$blnFound = true;
}
}
// If we didn't find an existing home phone, we will update the current primary (if applicable)
// Or create a new one as primary
if (!$blnFound) {
if (count($objHomePhoneArray)) {
$objHomePhoneArray[0]->Number = $strHomePhone;
$objHomePhoneArray[0]->Save();
} else {
$objPhone = new Phone();
$objPhone->Number = $strHomePhone;
$objPhone->Address = $objHomeAddress;
$objPhone->PhoneTypeId = PhoneType::Home;
$objPhone->Save();
$objPhone->SetAsPrimary(null, $objHomeAddress);
}
}
// Nope - we are deleting the home phone
} else {
foreach ($objHomePhoneArray as $objPhone) {
$objPhone->Delete();
}
}
// Not an existing Household CurrentAddress record that matches -- so we are creating a new one
} else {
$objAddress->Household = $objHousehold;
$objAddress->CurrentFlag = true;
$objAddress->AddressTypeId = AddressType::Home;
$objAddress->Save();
$objHousehold->SetAsCurrentAddress($objAddress);
// Add the phone if applicable
if ($strHomePhone) {
$objPhone = new Phone();
$objPhone->Number = $strHomePhone;
$objPhone->Address = $objAddress;
$objPhone->PhoneTypeId = PhoneType::Home;
$objPhone->Save();
$objPhone->SetAsPrimary(null, $objAddress);
}
}
// Mailing Address?
if ($objMailingAddressValidator) {
$objAddress = $objMailingAddressValidator->CreateAddressRecord();
$blnFound = false;
foreach ($this->GetAllAssociatedAddressArray($objHousehold) as $objExistingAddress) {
if ($objExistingAddress->IsEqualTo($objAddress)) {
$this->MailingAddress = $objExistingAddress;
$this->RefreshPrimaryContactInfo();
$blnFound = true;
}
}
if (!$blnFound) {
$objAddress->AddressTypeId = AddressType::Other;
$objAddress->Person = $this;
$objAddress->CurrentFlag = true;
$objAddress->Save();
//.........这里部分代码省略.........
示例2: GenerateAddressesForHousehold
protected static function GenerateAddressesForHousehold(Household $objHousehold)
{
// Add address and phone
$intAddressCount = rand(1, 5);
for ($i = 0; $i < $intAddressCount; $i++) {
$objAddress = new Address();
$objAddress->AddressTypeId = AddressType::Home;
$objAddress->Household = $objHousehold;
$objAddress->Address1 = QDataGen::GenerateStreetAddress();
if (rand(0, 1)) {
$objAddress->Address2 = QDataGen::GenerateAddressLine2();
}
$objAddress->City = QDataGen::GenerateCity();
$objAddress->State = QDataGen::GenerateUsState();
$objAddress->ZipCode = rand(10000, 99999);
$objAddress->Country = 'US';
$objAddress->InvalidFlag = false;
$objAddress->VerificationCheckedFlag = true;
$objAddress->CurrentFlag = $i + 1 == $intAddressCount;
$objAddress->Save();
$intPhoneCount = rand(1, 3);
for ($j = 0; $j < $intPhoneCount; $j++) {
$objPhone = new Phone();
$objPhone->PhoneTypeId = PhoneType::Home;
$objPhone->Address = $objAddress;
$objPhone->Number = QDataGen::GeneratePhone();
$objPhone->Save();
}
// Set the last one we created as "Primary"
$objPhone->SetAsPrimary();
}
}
示例3: Reconcile
//.........这里部分代码省略.........
}
if (!$blnFound) {
$objPhone = new Phone();
$objPhone->Number = $strMobilePhone;
$objPhone->PhoneTypeId = PhoneType::Mobile;
$objPhone->Save();
$objPerson->PrimaryPhone = $objPhone;
}
}
// Mailing Address
if ($objMailingAddress) {
$blnFound = false;
foreach ($objPerson->GetAllAssociatedAddressArray() as $objAddress) {
if ($objAddress->IsEqualTo($objMailingAddress)) {
$blnFound = true;
$objAddress->CurrentFlag = true;
$objAddress->AddressTypeId = AddressType::Other;
$objAddress->Save();
$objPerson->MailingAddress = $objAddress;
$objPerson->StewardshipAddress = $objAddress;
}
}
if (!$blnFound) {
$objMailingAddress->Person = $objPerson;
$objMailingAddress->CurrentFlag = true;
$objMailingAddress->AddressTypeId = AddressType::Other;
$objMailingAddress->Save();
$objPerson->MailingAddress = $objMailingAddress;
$objPerson->StewardshipAddress = $objMailingAddress;
}
}
// Home Address and Phone
$objHouseholdParticipationArray = $objPerson->GetHouseholdParticipationArray();
if (count($objHouseholdParticipationArray) == 1) {
$objHousehold = $objHouseholdParticipationArray[0]->Household;
$objAddress = $objHousehold->GetCurrentAddress();
if ($objAddress && $objAddress->IsEqualTo($objHomeAddress)) {
$objHomeAddress = $objAddress;
} else {
$objHomeAddress->AddressTypeId = AddressType::Home;
$objHomeAddress->Household = $objHousehold;
$objHomeAddress->CurrentFlag = true;
$objHomeAddress->Save();
if ($objAddress) {
$objAddress->CurrentFlag = false;
$objAddress->Save();
}
}
if ($strHomePhone) {
$blnFound = false;
foreach ($objHomeAddress->GetPhoneArray() as $objPhone) {
if ($objPhone->Number == $strHomePhone) {
$blnFound = true;
$objPhone->SetAsPrimary(null, $objHomeAddress);
}
}
if (!$blnFound) {
$objPhone = new Phone();
$objPhone->PhoneTypeId = PhoneType::Home;
$objPhone->Number = $strHomePhone;
$objPhone->Address = $objHomeAddress;
$objPhone->Save();
$objPhone->SetAsPrimary(null, $objHomeAddress);
}
}
} else {
if (count($objHouseholdParticipationArray) == 0) {
$objHousehold = Household::CreateHousehold($objPerson);
$objHomeAddress->AddressTypeId = AddressType::Home;
$objHomeAddress->Household = $objHousehold;
$objHomeAddress->CurrentFlag = true;
$objHomeAddress->Save();
$objHousehold->SetAsCurrentAddress($objHomeAddress);
if ($strHomePhone) {
$objPhone = new Phone();
$objPhone->PhoneTypeId = PhoneType::Home;
$objPhone->Number = $strHomePhone;
$objPhone->Address = $objHomeAddress;
$objPhone->Save();
$objPhone->SetAsPrimary(null, $objHomeAddress);
}
}
}
// Wire to PublicLogin
$this->PublicLogin->Person = $objPerson;
$this->PublicLogin->SetPassword($strPassword);
$this->PublicLogin->LostPasswordQuestion = trim($strQuestion);
$this->PublicLogin->LostPasswordAnswer = trim(strtolower($strAnswer));
$this->PublicLogin->DateLastLogin = QDateTime::Now();
$this->PublicLogin->Save();
// Save the person and delete the provision
$objPerson->RefreshPrimaryContactInfo();
$objPerson->RefreshAge(false);
$objPerson->RefreshNameItemAssociations(true);
$this->Delete();
// Commit to DB
Person::GetDatabase()->TransactionCommit();
// Return the now-linked person!
return $objPerson;
}