本文整理汇总了PHP中BaseElementModel::hasEagerLoadedElements方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::hasEagerLoadedElements方法的具体用法?PHP BaseElementModel::hasEagerLoadedElements怎么用?PHP BaseElementModel::hasEagerLoadedElements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::hasEagerLoadedElements方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasEagerLoadedElements
public function hasEagerLoadedElements($handle)
{
if (isset($this->_eagerLoadedBlockTypeElements[$handle])) {
return true;
}
return parent::hasEagerLoadedElements($handle);
}
示例2: hasEagerLoadedElements
/**
* @inheritDoc BaseElementModel::hasEagerLoadedElements()
*
* @param string $handle
*
* @return bool
*/
public function hasEagerLoadedElements($handle)
{
// See if we have this stored with a block type-specific handle
$blockTypeHandle = $this->getType()->handle . ':' . $handle;
if (isset($this->_eagerLoadedBlockTypeElements[$blockTypeHandle])) {
return true;
}
return parent::hasEagerLoadedElements($handle);
}
示例3: getTableAttributeHtml
/**
* @inheritDoc IElementType::getTableAttributeHtml()
*
* @param BaseElementModel $element
* @param string $attribute
*
* @return mixed|string
*/
public function getTableAttributeHtml(BaseElementModel $element, $attribute)
{
switch ($attribute) {
case 'link':
$url = $element->getUrl();
if ($url) {
return '<a href="' . $url . '" target="_blank" data-icon="world" title="' . Craft::t('Visit webpage') . '"></a>';
} else {
return '';
}
case 'uri':
$url = $element->getUrl();
if ($url) {
$value = $element->uri;
if ($value == '__home__') {
$value = '<span data-icon="home" title="' . Craft::t('Homepage') . '"></span>';
} else {
// Add some <wbr> tags in there so it doesn't all have to be on one line
$find = array('/');
$replace = array('/<wbr>');
$wordSeparator = craft()->config->get('slugWordSeparator');
if ($wordSeparator) {
$find[] = $wordSeparator;
$replace[] = $wordSeparator . '<wbr>';
}
$value = str_replace($find, $replace, $value);
}
return '<a href="' . $url . '" target="_blank" class="go" title="' . Craft::t('Visit webpage') . '"><span dir="ltr">' . $value . '</span></a>';
} else {
return '';
}
default:
// Is this a custom field?
if (preg_match('/^field:(\\d+)$/', $attribute, $matches)) {
$fieldId = $matches[1];
$field = craft()->fields->getFieldById($fieldId);
if ($field) {
$fieldType = $field->getFieldType();
if ($fieldType && $fieldType instanceof IPreviewableFieldType) {
// Was this field value eager-loaded?
if ($fieldType instanceof IEagerLoadingFieldType && $element->hasEagerLoadedElements($field->handle)) {
$value = $element->getEagerLoadedElements($field->handle);
} else {
$value = $element->getFieldValue($field->handle);
}
$fieldType->setElement($element);
return $fieldType->getTableAttributeHtml($value);
}
}
return '';
}
$value = $element->{$attribute};
if ($value instanceof DateTime) {
return '<span title="' . $value->localeDate() . ' ' . $value->localeTime() . '">' . $value->uiTimestamp() . '</span>';
}
return HtmlHelper::encode($value);
}
}