yii-gii
yii-gii copied to clipboard
Simple property mapper for ActiveRecord.
It would be great if the generated ActiveRecord had a property mapper. That is, create_at
was mapped to createAt
.
For example like this:
public function getAttributeMap(): array
{
return [
'createAt' => 'create_at',
];
}
public function __get(string $name)
{
return parent::__get($this->getAttributeMap()[$name] ?? $name);
}
public function __set(string $name, $value): void
{
parent::__set($this->getAttributeMap()[$name] ?? $name, $value);
}
public function __isset(string $name): bool
{
return parent::__isset($this->getAttributeMap()[$name] ?? $name);
}
public function __unset(string $name): void
{
return parent::__unset($this->getAttributeMap()[$name] ?? $name);
}
@property
will be appropriate.