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