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


PHP ViewableData::obj方法代码示例

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


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

示例1: obj

 /**
  * A wildcard method to handle calling specially named varchar fields, e.g. Email, URL.
  * @param  string $method The method name
  * @return mixed
  */
 public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null)
 {
     $varchar = DBField::create_field("Varchar", null, $fieldName);
     if ($data = $varchar->getDataByFieldName($this->getFaker())) {
         $varchar->setValue($data);
         return $varchar;
     }
     return parent::obj($fieldName);
 }
开发者ID:helpfulrobot,项目名称:unclecheese-mock-dataobjects,代码行数:14,代码来源:MockViewableData.php

示例2: obj

 /**
  * If we're publishing, returns proper php
  */
 public function obj($fieldName, $arguments = null, $forceReturnedObject = true, $cache = false, $cacheName = null)
 {
     $value = parent::obj($fieldName, $arguments, $forceReturnedObject, $cache, $cacheName);
     // if we're publishing and this variable is qualified, output php code instead
     if ($this->failover && $this->liveVars && isset($this->varName) && LivePubHelper::is_publishing() && $this->isLiveVar($fieldName)) {
         $accessor = "get{$fieldName}";
         $php = '';
         // find out how we got the data
         if ($this->failover instanceof ArrayData) {
             $php = '$' . $this->varName . '["' . $fieldName . '"]';
         } elseif (is_callable(array($this->failover, $fieldName))) {
             // !@TODO respect arguments
             $php = '$' . $this->varName . '->' . $fieldName . '()';
         } elseif (is_callable(array($this->failover, $accessor))) {
             // !@TODO respect arguments
             $php = '$' . $this->varName . '->' . $accessor . '()';
         } elseif (isset($this->failover, $fieldName)) {
             $php = '$' . $this->varName . '->' . $fieldName;
         }
         // return the appropriate php
         if ($php) {
             if (is_object($value)) {
                 if ($value instanceof ViewableWrapper) {
                     LivePubHelper::$init_code[] = '<?php $' . $value->getVar() . ' = ' . $php . ' ?>';
                 }
                 // !@TODO: only other option is DataObjectSet - check that this is handled right
             } else {
                 $value = in_array($fieldName, $this->liveVarsUnescaped) ? '<?php echo ' . $php . '; ?>' : '<?php echo htmlentities(' . $php . '); ?>';
                 if ($forceReturnedObject) {
                     $value = new HTMLText($value);
                 }
             }
         }
     }
     return $value;
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-livepub,代码行数:39,代码来源:ViewableWrapper.php


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