Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
ApexWire committed Nov 18, 2016
2 parents 3854818 + dbcddc1 commit 16cd8c5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use GuzzleHttp\Exception\ClientException;
use yii\base\InvalidConfigException;
use yii\base\NotSupportedException;
use yii\base\UnknownPropertyException;
use yii\db\BaseActiveRecord;
use yii\helpers\Inflector;
use yii\helpers\StringHelper;
Expand Down Expand Up @@ -235,4 +236,19 @@ public function unlinkAll($name, $delete = false)
{
throw new NotSupportedException('unlinkAll() is not supported by RestClient, use unlink() instead.');
}

/**
* @inheritdoc
* @throws \yii\base\UnknownPropertyException
*/
public static function populateRecord($record, $row)
{
$attributes = array_flip($record->attributes());
foreach ($attributes as $attributeName => $attributeValue) {
if (!array_key_exists($attributeName, $row)) {
throw new UnknownPropertyException("Attribute `{$attributeName}` not found in API response. Available fields: " . implode(', ', array_keys($row)) . '.');
}
}
parent::populateRecord($record, $row);
}
}

0 comments on commit 16cd8c5

Please sign in to comment.