Skip to content

Commit

Permalink
Issues [#1, #2] fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
jlorente committed Oct 14, 2015
1 parent 2f51d96 commit 6895e33
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
8 changes: 6 additions & 2 deletions src/ActiveRecordInheritanceTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 6895e33

Please sign in to comment.