From f228f21541850964cf2cd7d40f9f042819c1b5e5 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sat, 16 Nov 2013 15:10:33 +0200 Subject: [PATCH] "ActiveRelationInterface" applied to Sphinx Active Record. --- extensions/sphinx/ActiveRecord.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/extensions/sphinx/ActiveRecord.php b/extensions/sphinx/ActiveRecord.php index f821200..08617b4 100644 --- a/extensions/sphinx/ActiveRecord.php +++ b/extensions/sphinx/ActiveRecord.php @@ -12,6 +12,7 @@ use yii\base\InvalidParamException; use yii\base\Model; use yii\base\ModelEvent; use yii\base\UnknownMethodException; +use yii\db\ActiveRelationInterface; use yii\db\Expression; use yii\db\StaleObjectException; use yii\helpers\Inflector; @@ -324,8 +325,7 @@ class ActiveRecord extends Model return $this->_related[$name]; } $value = parent::__get($name); - // TODO: relation - if ($value instanceof ActiveRelation) { + if ($value instanceof ActiveRelationInterface) { return $this->_related[$name] = $value->multiple ? $value->all() : $value->one(); } else { return $value; @@ -1094,10 +1094,10 @@ class ActiveRecord extends Model /** * Returns the relation object with the specified name. - * A relation is defined by a getter method which returns an [[ActiveRelation]] object. + * A relation is defined by a getter method which returns an [[ActiveRelationInterface]] object. * It can be declared in either the Active Record class itself or one of its behaviors. * @param string $name the relation name - * @return ActiveRelation the relation object + * @return ActiveRelationInterface the relation object * @throws InvalidParamException if the named relation does not exist. */ public function getRelation($name) @@ -1105,7 +1105,7 @@ class ActiveRecord extends Model $getter = 'get' . $name; try { $relation = $this->$getter(); - if ($relation instanceof ActiveRelation) { + if ($relation instanceof ActiveRelationInterface) { return $relation; } else { return null;