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


PHP GridField::getCastedValue方法代码示例

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


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

示例1: castValue

 /**
  * Casts a field to a string which is safe to insert into HTML
  *
  * @param GridField $gridField GridField to cast value for
  * @param string    $fieldName Field name to cast value for
  * @param string    $value     Value to cast
  * 
  * @return string 
  * 
  * @author Sebastian Diel <sdiel@pixeltricks.de>
  * @since 26.03.2013
  */
 protected function castValue($gridField, $fieldName, $value)
 {
     // If a fieldCasting is specified, we assume the result is safe
     if (array_key_exists($fieldName, $this->fieldCasting)) {
         $value = $gridField->getCastedValue($value, $this->fieldCasting[$fieldName]);
     } else {
         if (is_object($value)) {
             // If the value is an object, we do one of two things
             if (method_exists($value, 'Nice')) {
                 // If it has a "Nice" method, call that & make sure the result is safe
                 $value = Convert::raw2xml($value->Nice());
             } else {
                 // Otherwise call forTemplate - the result of this should already be safe
                 $value = $value->forTemplate();
             }
         } elseif (!$this->isHtmlAllowedFor($fieldName, $gridField)) {
             // Otherwise, just treat as a text string & make sure the result is safe
             $value = Convert::raw2xml($value);
         }
     }
     return $value;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:34,代码来源:SilvercartGridFieldDataColumns.php

示例2: testGetCastedValueObject

 /**
  * @covers GridField::getCastedValue
  */
 public function testGetCastedValueObject()
 {
     $obj = new GridField('testfield', 'testfield');
     $value = $obj->getCastedValue('This is a sentance. This ia another.', 'Date');
     $this->assertEquals(null, $value);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:9,代码来源:GridFieldTest.php

示例3: castValue

 /**
  *
  * @param GridField $gridField
  * @param string $fieldName
  * @param string $value
  * @return string 
  */
 protected function castValue($gridField, $fieldName, $value)
 {
     if (array_key_exists($fieldName, $this->fieldCasting)) {
         return $gridField->getCastedValue($value, $this->fieldCasting[$fieldName]);
     } elseif (is_object($value) && method_exists($value, 'Nice')) {
         return $value->Nice();
     }
     return $value;
 }
开发者ID:nomidi,项目名称:sapphire,代码行数:16,代码来源:GridFieldDataColumns.php


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