-
Notifications
You must be signed in to change notification settings - Fork 0
/
DynamicModel.php
43 lines (38 loc) · 916 Bytes
/
DynamicModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
/**
* @copyright Copyright (c) 2014 Vitaliy Syrchikov
* @link http://syrchikov.name
*/
namespace maddoger\core;
use Yii;
/**
* DynamicModel for attribute labels support
*
* @author Vitaliy Syrchikov <maddoger@gmail.com>
* @link http://syrchikov.name
* @package maddoger/yii2-core
*/
class DynamicModel extends \yii\base\DynamicModel
{
private $_attributeLabels;
/**
* Defines an attribute.
* @param string $name the attribute name
* @param mixed $value the attribute value
* @param string $label the attribute label
*/
public function defineAttribute($name, $value = null, $label = null)
{
if ($label) {
$this->_attributeLabels[$name] = $label;
}
parent::defineAttribute($name, $value);
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return $this->_attributeLabels;
}
}