Skip to content

Commit

Permalink
- Removed ActiveRecord::arrayAttributes method
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Oct 26, 2015
1 parent bc3cf50 commit 9d72ad6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 34 deletions.
2 changes: 1 addition & 1 deletion src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private function createModels($rows)
*/
public function populateJoinedRelations($model, array $row) {
foreach ($row as $key => $value) {
if (!is_array($value) || $model->hasAttribute($key)) continue;
if (empty($this->join) || !is_array($value) || $model->hasAttribute($key)) continue;
foreach ($this->join as $name) {
if ($model->isRelationPopulated($name)) continue 2;
$records = [];
Expand Down
33 changes: 0 additions & 33 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,6 @@ public function attributes()
throw new InvalidConfigException('The attributes() method of Hiresource ActiveRecord has to be implemented by child classes.');
}

/**
* A list of attributes that should be treated as array valued when retrieved through [[ActiveQuery::fields]].
*
* If not listed by this method, attributes retrieved through [[ActiveQuery::fields]] will converted to a scalar value
* when the result array contains only one value.
*
* @return string[] list of attribute names. Must be a subset of [[attributes()]].
*/
public function arrayAttributes()
{
return [];
}

/**
* @return string the name of the index this record is stored in.
*/
Expand All @@ -217,26 +204,6 @@ public static function joinIndex()
return static::index();
}

/**
* @inheritdoc
*
* @param ActiveRecord $record the record to be populated. In most cases this will be an instance
* created by [[instantiate()]] beforehand.
* @param array $row attribute values (name => value)
*/
public static function populateRecord($record, $row)
{
$arrayAttributes = array_flip($record->arrayAttributes());
foreach ($row as $key => $value) {
if (is_array($value) && !isset($arrayAttributes[$key]) && count($value) == 1) {
$row[$key] = reset($value);
}
}
$attributes = $row;

parent::populateRecord($record, $attributes);
}

/**
* Creates an active record instance.
*
Expand Down

0 comments on commit 9d72ad6

Please sign in to comment.