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


PHP CustomFieldData::getById方法代碼示例

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


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

示例1: testSaveAndLoadCustomFieldData

 public function testSaveAndLoadCustomFieldData()
 {
     $values = array('Item 1', 'Item 2', 'Item 3');
     $labels = array('fr' => 'Item 1 fr', 'fr' => 'Item 2 fr', 'fr' => 'Item 3 fr');
     $customFieldData = CustomFieldData::getByName('Items');
     $customFieldData->serializedData = serialize($values);
     $customFieldData->serializedLabels = serialize($labels);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     unset($customFieldData);
     $customFieldData = CustomFieldData::getById($id);
     $loadedValues = unserialize($customFieldData->serializedData);
     $loadedLabels = unserialize($customFieldData->serializedLabels);
     $this->assertEquals('Items', $customFieldData->name);
     $this->assertNull($customFieldData->defaultValue);
     $this->assertEquals($values, $loadedValues);
     $this->assertEquals($labels, $loadedLabels);
     $customFieldData->defaultValue = $values[2];
     $this->assertTrue($customFieldData->save());
     unset($customFieldData);
     $customFieldData = CustomFieldData::getById($id);
     $this->assertEquals('Items', $customFieldData->name);
     $this->assertEquals('Item 3', $customFieldData->defaultValue);
     $this->assertEquals($values, $loadedValues);
 }
開發者ID:maruthisivaprasad,項目名稱:zurmo,代碼行數:25,代碼來源:CustomFieldTest.php

示例2: testSetAndGetEmptyValueWhichShouldUtilizeFallBack

 public function testSetAndGetEmptyValueWhichShouldUtilizeFallBack()
 {
     $this->assertEquals('en', Yii::app()->language);
     $values = array('Item 1', 'Item 2', 'Item 3');
     $labels = array('fr' => array('Item 1 fr', '', 'Item 3 fr'));
     $customFieldData = CustomFieldData::getByName('Items2');
     $customFieldData->serializedData = serialize($values);
     $customFieldData->serializedLabels = serialize($labels);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     $customFieldData->forget();
     unset($customFieldData);
     $customFieldData = CustomFieldData::getById($id);
     $dataAndLabels = CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($customFieldData, 'en');
     $compareData = array('Item 1' => 'Item 1', 'Item 2' => 'Item 2', 'Item 3' => 'Item 3');
     $this->assertEquals($compareData, $dataAndLabels);
     $dataAndLabels = CustomFieldDataUtil::getDataIndexedByDataAndTranslatedLabelsByLanguage($customFieldData, 'fr');
     $compareData = array('Item 1' => 'Item 1 fr', 'Item 2' => 'Item 2', 'Item 3' => 'Item 3 fr');
     $this->assertEquals($compareData, $dataAndLabels);
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:20,代碼來源:CustomFieldDataUtilTest.php

示例3: testGetTranslatedLabelByValue

 public function testGetTranslatedLabelByValue()
 {
     $this->assertEquals('en', Yii::app()->language);
     $values = array('Item 1', 'Item 2', 'Item 3');
     $labels = array('fr' => array('Item 1 fr', '', 'Item 3 fr'));
     $customFieldData = CustomFieldData::getByName('Items2');
     $customFieldData->serializedData = serialize($values);
     $customFieldData->serializedLabels = serialize($labels);
     $this->assertTrue($customFieldData->save());
     $id = $customFieldData->id;
     $customFieldData->forget();
     unset($customFieldData);
     $customFieldData = CustomFieldData::getById($id);
     $value = CustomFieldDataUtil::getTranslatedLabelByValue($customFieldData, 'Item 1', 'en');
     $this->assertEquals('Item 1', $value);
     $value = CustomFieldDataUtil::getTranslatedLabelByValue($customFieldData, 'Item 1', 'fr');
     $this->assertEquals('Item 1 fr', $value);
 }
開發者ID:youprofit,項目名稱:Zurmo,代碼行數:18,代碼來源:CustomFieldDataUtilTest.php


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