当前位置: 首页>>代码示例>>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;未经允许,请勿转载。