本文整理汇总了PHP中BaseElementModel::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseElementModel::getAttribute方法的具体用法?PHP BaseElementModel::getAttribute怎么用?PHP BaseElementModel::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseElementModel
的用法示例。
在下文中一共展示了BaseElementModel::getAttribute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getDimension
/**
* Return a dimension of the image.
*
* @param $dimension 'height' or 'width'
* @param $transform
*
* @return null|float|mixed
*/
private function _getDimension($dimension, $transform)
{
if ($this->kind != 'image') {
return null;
}
if ($transform === null && isset($this->_transform)) {
$transform = $this->_transform;
}
if (!$transform) {
return parent::getAttribute($dimension);
}
$transform = craft()->assetTransforms->normalizeTransform($transform);
$dimensions = array('width' => $transform->width, 'height' => $transform->height);
if (!$transform->width || !$transform->height) {
// Fill in the blank
$dimensionArray = ImageHelper::calculateMissingDimension($dimensions['width'], $dimensions['height'], $this->_getWidth(), $this->_getHeight());
$dimensions['width'] = (int) $dimensionArray[0];
$dimensions['height'] = (int) $dimensionArray[1];
}
// Special case for 'fit' since that's the only one whose dimensions vary from the transform dimensions
if ($transform->mode == 'fit') {
$factor = max($this->_getWidth() / $dimensions['width'], $this->_getHeight() / $dimensions['height']);
$dimensions['width'] = (int) round($this->_getWidth() / $factor);
$dimensions['height'] = (int) round($this->_getHeight() / $factor);
}
return $dimensions[$dimension];
}
示例2: _getHeight
/**
* Returns the actual height attribute, since $this->height gets routed to getHeight() now.
*
* @access private
* @return mixed
*/
private function _getHeight()
{
return parent::getAttribute('height');
}