當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContactState::save方法代碼示例

本文整理匯總了PHP中ContactState::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContactState::save方法的具體用法?PHP ContactState::save怎麽用?PHP ContactState::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ContactState的用法示例。


在下文中一共展示了ContactState::save方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: loadStartingData

 /**
  * Used on first load to install ContactState data
  * and the startingState for the Contacts module.
  * @return true/false if data was in fact loaded.
  */
 public static function loadStartingData()
 {
     if (count(ContactState::GetAll()) != 0) {
         return false;
     }
     $data = array(Zurmo::t('Core', 'New'), Zurmo::t('Core', 'In Progress'), Zurmo::t('ContactsModule', 'Recycled'), Zurmo::t('ContactsModule', 'Dead'), Zurmo::t('ContactsModule', 'Qualified'), Zurmo::t('ZurmoModule', 'Customer'));
     $order = 0;
     $startingStateId = null;
     foreach ($data as $stateName) {
         $state = new ContactState();
         $state->name = $stateName;
         $state->order = $order;
         $saved = $state->save();
         assert('$saved');
         if ($stateName == Zurmo::t('ContactsModule', 'Qualified')) {
             $startingStateId = $state->id;
         }
         $order++;
     }
     if ($startingStateId == null) {
         throw new NotSupportedException();
     }
     $metadata = ContactsModule::getMetadata();
     $metadata['global']['startingStateId'] = $startingStateId;
     ContactsModule::setMetadata($metadata);
     assert('count(ContactState::GetAll()) == 6');
     return true;
 }
開發者ID:maruthisivaprasad,項目名稱:zurmo,代碼行數:33,代碼來源:ContactsModule.php

示例2: 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

示例3: setAttributeMetadataFromForm

 public function setAttributeMetadataFromForm(AttributeForm $attributeForm)
 {
     $modelClassName = get_class($this->model);
     $attributeName = $attributeForm->attributeName;
     $attributeLabels = $attributeForm->attributeLabels;
     $elementType = $attributeForm->getAttributeTypeName();
     $isRequired = (bool) $attributeForm->isRequired;
     $isAudited = (bool) $attributeForm->isAudited;
     $contactStatesData = $attributeForm->contactStatesData;
     $contactStatesLabels = $attributeForm->contactStatesLabels;
     $startingStateOrder = (int) $attributeForm->startingStateOrder;
     $contactStatesDataExistingValues = $attributeForm->contactStatesDataExistingValues;
     if ($contactStatesDataExistingValues == null) {
         $contactStatesDataExistingValues = array();
     }
     if ($attributeForm instanceof ContactStateAttributeForm) {
         //update order on existing states.
         //delete removed states
         $states = ContactState::getAll('order');
         $stateNames = array();
         foreach ($states as $state) {
             if (in_array($state->name, $contactStatesData)) {
                 $stateNames[] = $state->name;
                 $state->order = array_search($state->name, $contactStatesData);
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
             } elseif (in_array($state->name, $contactStatesDataExistingValues)) {
                 $order = array_search($state->name, $contactStatesDataExistingValues);
                 $state->name = $contactStatesData[$order];
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $state->order);
                 $saved = $state->save();
                 assert('$saved');
                 $stateNames[] = $state->name;
             } else {
                 $stateNames[] = $state->name;
                 $state->delete();
             }
         }
         //add new states with correct order.
         foreach ($contactStatesData as $order => $name) {
             if (!in_array($name, $stateNames)) {
                 $state = new ContactState();
                 $state->name = $name;
                 $state->order = $order;
                 $state->serializedLabels = $this->makeSerializedLabelsByLabelsAndOrder($contactStatesLabels, (int) $order);
                 $saved = $state->save();
                 assert('$saved');
             }
         }
         //Set starting state by order.
         ContactsUtil::setStartingStateByOrder($startingStateOrder);
         ModelMetadataUtil::addOrUpdateRelation($modelClassName, $attributeName, $attributeLabels, $elementType, $isRequired, $isAudited, 'ContactState');
     } else {
         throw new NotSupportedException();
     }
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:58,代碼來源:ContactStateModelAttributesAdapter.php


注:本文中的ContactState::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。