Browse Source

Sphinx Active Record relation handling provided.

tags/2.0.0-beta
Klimov Paul 11 years ago
parent
commit
0bc91f29e7
  1. 23
      extensions/sphinx/ActiveRecord.php
  2. 4
      tests/unit/data/sphinx/ar/ArticleDb.php
  3. 4
      tests/unit/data/sphinx/ar/ItemDb.php

23
extensions/sphinx/ActiveRecord.php

@ -1126,4 +1126,27 @@ class ActiveRecord extends Model
$transactions = $this->transactions();
return isset($transactions[$scenario]) && ($transactions[$scenario] & $operation);
}
/**
* Sets the element at the specified offset.
* This method is required by the SPL interface `ArrayAccess`.
* It is implicitly called when you use something like `$model[$offset] = $item;`.
* @param integer $offset the offset to set element
* @param mixed $item the element value
* @throws \Exception on failure
*/
public function offsetSet($offset, $item)
{
// Bypass relation owner restriction to 'yii\db\ActiveRecord' at [[ActiveRelationTrait::findWith()]]:
try {
$relation = $this->getRelation($offset);
if (is_object($relation)) {
$this->populateRelation($offset, $item);
return;
}
} catch (UnknownMethodException $e) {
throw $e->getPrevious();
}
parent::offsetSet($offset, $item);
}
}

4
tests/unit/data/sphinx/ar/ArticleDb.php

@ -2,9 +2,9 @@
namespace yiiunit\data\sphinx\ar;
use yiiunit\data\ar;
use yiiunit\data\ar\ActiveRecord as ActiveRecordDb;
class ArticleDb extends ActiveRecord
class ArticleDb extends ActiveRecordDb
{
public static function tableName()
{

4
tests/unit/data/sphinx/ar/ItemDb.php

@ -2,9 +2,9 @@
namespace yiiunit\data\sphinx\ar;
use yiiunit\data\ar;
use yiiunit\data\ar\ActiveRecord as ActiveRecordDb;
class ItemDb extends ActiveRecord
class ItemDb extends ActiveRecordDb
{
public static function tableName()
{

Loading…
Cancel
Save