本文整理匯總了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);
}
示例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;
}