credy / yii2-rename-behavior
Rename attributes on models.
Installs: 18
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
Type:yii2-extension
pkg:composer/credy/yii2-rename-behavior
Requires
- yiisoft/yii2: ^2.0
Requires (Dev)
- codeception/codeception: ^5.0.0 || ^4.0
- codeception/module-asserts: ^3.0 || ^1.1
- codeception/module-phpbrowser: *
- codeception/module-yii2: ^1.1
- credy/tc-coding-standard: dev-master
- dealerdirect/phpcodesniffer-composer-installer: ^0.7.0
- yiisoft/yii2-redis: ^2.0
This package is auto-updated.
Last update: 2025-11-13 13:21:14 UTC
README
With this behavior, you can rename attributes on components in Yii2
Usage
public function behaviors()
{
return [
'renameBehavior' => \credy\behavior\rename\RenameBehavior::class,
'renames' => [
'renamedAttributeName' => 'realAttributeName'
]
]
}
You can also define get and set methods that modify the data
public function behaviors()
{
return [
'renameBehavior' => \credy\behavior\rename\RenameBehavior::class,
'renames' => [
'renamedAttributeName' => 'realAttributeName'
],
'getMethod' => [self::class, 'getModifiedAttribute'],
'setMethod' => [self::class, 'setModifiedAttribute'],
];
}
public static function getModifiedAttribute($value, $attributeName)
{
// do some modifications here
return 'modified attribute value';
}
public static function setModifiedAttribute($value, $attributeName)
{
// do some modifications here
return 'modified attribute value';
}