當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。