Browse Source

moved indexBy() trait -> interface + removed findWith from interface

tags/2.0.0-beta
Carsten Brandt 11 years ago
parent
commit
1acdbb741c
  1. 19
      framework/yii/ar/ActiveQueryInterface.php
  2. 22
      framework/yii/ar/ActiveQueryTrait.php
  3. 9
      framework/yii/ar/ActiveRelationInterface.php

19
framework/yii/ar/ActiveQueryInterface.php

@ -27,6 +27,25 @@ interface ActiveQueryInterface extends QueryInterface
public function asArray($value = true); public function asArray($value = true);
/** /**
* Sets the [[indexBy]] property.
* @param string|callable $column the name of the column by which the query results should be indexed by.
* This can also be a callable (e.g. anonymous function) that returns the index value based on the given
* row or model data. The signature of the callable should be:
*
* ~~~
* // $model is an AR instance when `asArray` is false,
* // or an array of column values when `asArray` is true.
* function ($model)
* {
* // return the index value corresponding to $model
* }
* ~~~
*
* @return static the query object itself
*/
public function indexBy($column);
/**
* Specifies the relations with which this query should be performed. * Specifies the relations with which this query should be performed.
* *
* The parameters to this method can be either one or multiple strings, or a single array * The parameters to this method can be either one or multiple strings, or a single array

22
framework/yii/ar/ActiveQueryTrait.php

@ -103,28 +103,6 @@ trait ActiveQueryTrait
} }
/** /**
* Sets the [[indexBy]] property.
* @param string|callable $column the name of the column by which the query results should be indexed by.
* This can also be a callable (e.g. anonymous function) that returns the index value based on the given
* row or model data. The signature of the callable should be:
*
* ~~~
* // $model is an AR instance when `asArray` is false,
* // or an array of column values when `asArray` is true.
* function ($model)
* {
* // return the index value corresponding to $model
* }
* ~~~
*
* @return static the query object itself
*/
public function indexBy($column)
{
return parent::indexBy($column);
}
/**
* Converts found rows into model instances * Converts found rows into model instances
* @param array $rows * @param array $rows
* @return array|ActiveRecord[] * @return array|ActiveRecord[]

9
framework/yii/ar/ActiveRelationInterface.php

@ -26,13 +26,4 @@ interface ActiveRelationInterface extends ActiveQueryInterface
* @return static the relation object itself. * @return static the relation object itself.
*/ */
public function via($relationName, $callable = null); public function via($relationName, $callable = null);
/**
* Finds the related records and populates them into the primary models.
* This method is internally used by [[ActiveQuery]]. Do not call it directly.
* @param string $name the relation name
* @param array $primaryModels primary models
* @return array the related models
*/
public function findWith($name, &$primaryModels);
} }

Loading…
Cancel
Save