diff --git a/.gitignore b/.gitignore index 1ffd740..0e06e2a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,35 @@ +# yii console command +/yii + +# phpstorm project files +.idea + +# netbeans project files nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# composer vendor dir +/vendor + +# composer itself is not needed +composer.phar + +# Mac DS_Store Files +.DS_Store +.AppleDouble + +# phpunit itself is not needed +phpunit.phar + +# local phpunit config +/phpunit.xml + +# composer lock +composer.lock \ No newline at end of file diff --git a/src/ActiveRecordInheritanceTrait.php b/src/ActiveRecordInheritanceTrait.php index 9b6513f..134468e 100644 --- a/src/ActiveRecordInheritanceTrait.php +++ b/src/ActiveRecordInheritanceTrait.php @@ -15,6 +15,7 @@ use yii\base\Exception as BaseException; use Yii; use Exception; +use yii\db\ActiveRecord; /** * Trait to simulate inheritance between two ActiveRecordInterface classes. @@ -199,7 +200,10 @@ public function attributeLabels() { * @return array attribute values (name => value). */ public function getAttributes($names = null, $except = array()) { - return array_merge($this->_parent()->getAttributes($names, $except), parent::getAttributes($names, $except)); + if ($names === null) { + $names = array_merge($this->_parent()->attributes(), $this->attributes()); + } + return parent::getAttributes($names, $except); } /** @@ -366,7 +370,7 @@ public function getFirstErrors() { */ public function getFirstError($attribute) { $errors = $this->getErrors($attribute); - return empty($errors[$attribute]) ? null : $errors[0]; + return count($errors) ? $errors[0] : null; } /**