Skip to content

Commit

Permalink
removed primaryValue from ActiveRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Jan 27, 2017
1 parent 1f652c8 commit 5f11ea8
Showing 1 changed file with 0 additions and 58 deletions.
58 changes: 0 additions & 58 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,64 +94,6 @@ public static function primaryKey()
return ['id'];
}

/**
* + * The name of the main attribute
* + *
* Examples:.
*
* This will directly reference to the attribute 'name'
* ```
* return 'name';
* ```
*
* This will concatenate listed attributes, separated with `delimiter` value.
* If delimiter is not set, space is used by default.
* ```
* return ['seller', 'client', 'delimiter' => '/'];
* ```
*
* The callable method, that will get [[$model]] and should return value of name attribute
* ```
* return function ($model) {
* return $model->someField ? $model->name : $model->otherName;
* };
* ```
*
* @throws InvalidConfigException
*
* @return string|callable|array
*
* @author SilverFire
*/
public function primaryValue()
{
return static::formName();
}

/**
* Returns the value of the primary attribute.
*
* @throws InvalidConfigException
*
* @return mixed|null
*
* @see primaryValue()
*/
public function getPrimaryValue()
{
$primaryValue = $this->primaryValue();

if ($primaryValue instanceof \Closure) {
return call_user_func($primaryValue, [$this]);
} elseif (is_array($primaryValue)) {
$delimiter = ArrayHelper::remove($primaryValue, 'delimiter', ' ');

return implode($delimiter, $this->getAttributes($primaryValue));
} else {
return $this->getAttribute($primaryValue);
}
}

/**
* Returns the list of attribute names.
* By default, this method returns all attributes mentioned in rules.
Expand Down

0 comments on commit 5f11ea8

Please sign in to comment.