当前位置: 首页>>代码示例>>PHP>>正文


PHP ContactState::getById方法代码示例

本文整理汇总了PHP中ContactState::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactState::getById方法的具体用法?PHP ContactState::getById怎么用?PHP ContactState::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContactState的用法示例。


在下文中一共展示了ContactState::getById方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sanitizeValue

 /**
  * Given a contact state id, attempt to get and return a contact state object. If the id is invalid, then an
  * InvalidValueToSanitizeException will be thrown.
  * @param mixed $value
  * @return sanitized value
  * @throws InvalidValueToSanitizeException
  * @throws NotFoundException
  */
 public function sanitizeValue($value)
 {
     assert('$this->attributeName == null');
     if ($value == null) {
         return $value;
     }
     try {
         if ((int) $value <= 0) {
             $states = ContactState::getByName($value);
             if (count($states) > 1) {
                 throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'Status specified is not unique and is invalid.'));
             } elseif (count($states) == 0) {
                 throw new NotFoundException();
             }
             $state = $states[0];
         } else {
             $state = ContactState::getById($value);
         }
         $startingState = ContactsUtil::getStartingState();
         if (!static::resolvesValidStateByOrder($state->order, $startingState->order)) {
             throw new InvalidValueToSanitizeException(Zurmo::t('ZurmoModule', 'Status specified is invalid.'));
         }
         return $state;
     } catch (NotFoundException $e) {
         throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'Status specified does not exist.'));
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:35,代码来源:ContactStateSanitizerUtil.php

示例2: resolveValueAndSetToModel

 /**
  * Utilized to create or update model attribute values after a workflow's triggers are fired as true.
  * @param WorkflowActionProcessingModelAdapter $adapter
  * @param string $attribute
  * @throws NotSupportedException
  */
 public function resolveValueAndSetToModel(WorkflowActionProcessingModelAdapter $adapter, $attribute)
 {
     assert('is_string($attribute)');
     if ($this->type == WorkflowActionAttributeForm::TYPE_STATIC) {
         $adapter->getModel()->{$attribute} = ContactState::getById((int) $this->value);
         //todo: what if it doesn't exist anymore?
     } else {
         throw new NotSupportedException();
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:16,代码来源:ContactStateWorkflowActionAttributeForm.php

示例3: testCreateAndGetContactState

 public function testCreateAndGetContactState()
 {
     $state = new ContactState();
     $state->name = 'First State';
     $state->order = 0;
     $this->assertTrue($state->save());
     $id = $state->id;
     unset($state);
     $state = ContactState::getById($id);
     $this->assertEquals('First State', $state->name);
     $this->assertEquals(0, $state->order);
     $state->delete();
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:13,代码来源:ContactStateTest.php

示例4: sanitizeValue

 /**
  * Contact state is required.  If the value provided is null then the sanitizer will attempt use a default
  * value if provided.  If this is missing then a InvalidValueToSanitizeException will be thrown.
  * @param mixed $value
  * @return sanitized value
  * @throws InvalidValueToSanitizeException
  */
 public function sanitizeValue($value)
 {
     assert('$this->attributeName == null');
     assert('is_string($value) || $value == null || $value instanceof ContactState');
     $modelClassName = $this->modelClassName;
     $model = new $modelClassName(false);
     if ($value == null) {
         if (isset($this->mappingRuleData['defaultStateId']) && $this->mappingRuleData['defaultStateId'] != null) {
             try {
                 $state = ContactState::getById((int) $this->mappingRuleData['defaultStateId']);
             } catch (NotFoundException $e) {
                 throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The default status specified does not exist.'));
             }
             return $state;
         } else {
             throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status is required.  Neither a value nor a default was specified.'));
         }
     }
     return $value;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactStateRequiredSanitizerUtil.php

示例5: testRenderHtmlContentLabelFromContactAndKeyword

 public function testRenderHtmlContentLabelFromContactAndKeyword()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $contact = new Contact();
     $contact->firstName = 'johnny';
     $contact->lastName = 'five';
     $contact->owner = $super;
     $contact->state = ContactState::getById(5);
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = 'a@a.com';
     $this->assertTrue($contact->save());
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $contact2 = new Contact();
     $contact2->firstName = 'johnny';
     $contact2->lastName = 'six';
     $contact2->owner = $super;
     $contact2->state = ContactState::getById(5);
     $contact2->primaryEmail = new Email();
     $contact2->primaryEmail->emailAddress = 'a@a.com';
     $contact2->secondaryEmail = new Email();
     $contact2->secondaryEmail->emailAddress = 'b@b.com';
     $this->assertTrue($contact2->save());
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $contact3 = new Contact();
     $contact3->firstName = 'johnny';
     $contact3->lastName = 'seven';
     $contact3->owner = $super;
     $contact3->state = ContactState::getById(5);
     $this->assertTrue($contact3->save());
     $content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact, 'asdad');
     $this->assertEquals('johnny five&#160&#160<b>a@a.com</b>', $content);
     $content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact2, 'b@b');
     $this->assertEquals('johnny six&#160&#160<b>b@b.com</b>', $content);
     $content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact2, 'cc');
     $this->assertEquals('johnny six&#160&#160<b>a@a.com</b>', $content);
     $content = MultipleContactsForMeetingElement::renderHtmlContentLabelFromContactAndKeyword($contact3, 'cx');
     $this->assertEquals('johnny seven', $content);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:41,代码来源:MultipleContactsForMeetingElementTest.php

示例6: getStartingState

 /**
  * @return ContactState object
  */
 public static function getStartingState()
 {
     $metadata = ContactsModule::getMetadata();
     return ContactState::getById($metadata['global']['startingStateId']);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:8,代码来源:ContactsUtil.php

示例7: testContactsUtilSetStartingStateByOrder

 public function testContactsUtilSetStartingStateByOrder()
 {
     $startingStateId = ContactsUtil::getStartingStateId();
     $startingState = ContactState::getById($startingStateId);
     $startingState->delete();
     $this->assertEquals(6, count(ContactState::GetAll()));
     ContactsUtil::setStartingStateByOrder(2);
     $startingStateId = ContactsUtil::getStartingStateId();
     $states = ContactState::getAll('order');
     $this->assertEquals($states[1]->id, $startingStateId);
     $startingState = ContactState::getByName('Recycled');
     $this->assertEquals(1, count($startingState));
     $this->assertEquals($startingState[0]->id, $startingStateId);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:14,代码来源:ContactTest.php

示例8: testAttributesToAccount

 /**
  * @depends testCreateStateValues
  */
 public function testAttributesToAccount()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $industries = array('Automotive', 'Adult Entertainment', 'Financial Services', 'Mercenaries & Armaments');
     $industryFieldData = CustomFieldData::getByName('Industries');
     $industryFieldData->serializedData = serialize($industries);
     $this->assertTrue($industryFieldData->save());
     $user = UserTestHelper::createBasicUser('Bobby');
     $contact = new Contact();
     $contact->owner = $user;
     $contact->title->value = 'Mr.';
     $contact->firstName = 'Super';
     $contact->lastName = 'Man';
     $contact->companyName = 'ABC Company';
     $stateIds = ContactsUtil::getContactStateDataKeyedById();
     foreach ($stateIds as $stateId => $notUsed) {
         $stateToUse = ContactState::getById($stateId);
         break;
     }
     $contact->state = $stateToUse;
     //grab first state.
     $contact->officePhone = '1234567890';
     $contact->officeFax = '1222222222';
     $contact->industry->value = $industries[1];
     $contact->website = 'http://www.something.com';
     $contact->primaryAddress->street1 = '129 Noodle Boulevard';
     $contact->primaryAddress->street2 = 'Apartment 6000A';
     $contact->primaryAddress->city = 'Noodleville';
     $contact->primaryAddress->postalCode = '23453';
     $contact->primaryAddress->country = 'The Good Old US of A';
     $contact->secondaryAddress->street1 = '25 de Agosto 2543';
     $contact->secondaryAddress->street2 = 'Local 3';
     $contact->secondaryAddress->city = 'Ciudad de Los Fideos';
     $contact->secondaryAddress->postalCode = '5123-4';
     $contact->secondaryAddress->country = 'Latinoland';
     $this->assertTrue($contact->save());
     $id = $contact->id;
     unset($contact);
     $contact = Contact::getById($id);
     $account = new Account();
     $account = LeadsUtil::attributesToAccount($contact, $account);
     $this->assertTrue($account->save());
     $id = $account->id;
     unset($account);
     $account = Account::getById($id);
     $this->assertEquals('ABC Company', $account->name);
     $this->assertEquals('1234567890', $account->officePhone);
     $this->assertEquals('1222222222', $account->officeFax);
     $this->assertEquals('http://www.something.com', $account->website);
     $this->assertEquals($industries[1], $account->industry->value);
     $this->assertEquals('super', $account->owner->username);
     $this->assertEquals('129 Noodle Boulevard', $account->billingAddress->street1);
     $this->assertEquals('Apartment 6000A', $account->billingAddress->street2);
     $this->assertEquals('Noodleville', $account->billingAddress->city);
     $this->assertEquals('23453', $account->billingAddress->postalCode);
     $this->assertEquals('The Good Old US of A', $account->billingAddress->country);
     $this->assertEquals('25 de Agosto 2543', $account->shippingAddress->street1);
     $this->assertEquals('Local 3', $account->shippingAddress->street2);
     $this->assertEquals('Ciudad de Los Fideos', $account->shippingAddress->city);
     $this->assertEquals('5123-4', $account->shippingAddress->postalCode);
     $this->assertEquals('Latinoland', $account->shippingAddress->country);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:65,代码来源:LeadTest.php


注:本文中的ContactState::getById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。