本文整理汇总了PHP中BaseModel::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::getAttribute方法的具体用法?PHP BaseModel::getAttribute怎么用?PHP BaseModel::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::getAttribute方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslatedDefinition
/**
* Returns the translated definition for the word hatred
*
* {Injects a static method dependency for Craft::t}
*
* @param string $translator The name of the static class that defines t()
*
* @return string
*/
public function getTranslatedDefinition(BaseModel $model)
{
if ($model->validate()) {
// Static method dependencies are just not elegant to work with
// We can use $model->property but using $model->getAttribute('property') make this method more testable
return call_user_func_array($this->translator . '::t', array($model->getAttribute('definition')));
}
return false;
}
示例2: getAttribute
/**
* Gets an attribute's value.
*
* @param string $name
* @param bool $flattenValue
* @return mixed
*/
public function getAttribute($name, $flattenValue = false)
{
// Flatten packages into a comma-delimited string, rather than JSON
if ($name == 'packages' && $flattenValue) {
return implode(',', parent::getAttribute('packages'));
} else {
return parent::getAttribute($name, $flattenValue);
}
}
示例3: getAttribute
/**
* Modify default behavior of getAttribute to include Meta value into this model attributes.
*
* @param string $key
* @return mixed
*/
public function getAttribute($key)
{
if (in_array($key, $this->metaKeys)) {
return $this->getMetaKeyValue($key);
}
return parent::getAttribute($key);
}
示例4: getAttribute
/**
* @inheritDoc BaseModel::getAttribute()
*
* @param string $name
* @param bool $flattenValue
*
* @return mixed
*/
public function getAttribute($name, $flattenValue = false)
{
return parent::getAttribute($name, $flattenValue);
}
示例5: getAttribute
/**
* @inheritDoc BaseModel::getAttribute()
*
* @param string $name
* @param bool $flattenValue
*
* @return mixed
*/
public function getAttribute($name, $flattenValue = false)
{
$value = parent::getAttribute($name, $flattenValue);
if ($name == 'path' && !empty($value)) {
$value = rtrim($value, '/') . '/';
}
return $value;
}
示例6: getAttribute
/**
* Inject our model attribute accessors.
*
* @param String $string
* @return String
*/
public function getAttribute($name)
{
switch ($name) {
case 'baseUrl':
return $this->getBaseUrl();
break;
case 'cachePath':
return $this->getCachePath();
break;
case 'cacheUrl':
return $this->getCacheUrl();
break;
case 'cssReturnTemplate':
return $this->getCssReturnTemplate();
break;
case 'filesystemPath':
return $this->getFilesystemPath();
break;
case 'jsReturnTemplate':
return $this->getJsReturnTemplate();
break;
case 'returnType':
return $this->getReturnType();
break;
}
return parent::getAttribute($name);
}
示例7: getAttribute
/**
* Inject our model attribute accessors.
*
* @param String $name
* @param Bool $flattenValue
* @return String|Bool
*/
public function getAttribute($name, $flattenValue = false)
{
switch ($name) {
case 'baseUrl':
return $this->getBaseUrl();
case 'cachePath':
return $this->getCachePath();
case 'cacheUrl':
return $this->getCacheUrl();
case 'cssReturnTemplate':
return $this->getCssReturnTemplate();
case 'cssPrependUrl':
return $this->getCssPrependUrl();
case 'filesystemPath':
return $this->getFilesystemPath();
case 'jsReturnTemplate':
return $this->getJsReturnTemplate();
case 'returnType':
return $this->getReturnType();
default:
return parent::getAttribute($name, $flattenValue);
}
}