本文整理汇总了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;
}