From 5a8afcf7200fc3c60e971663b4413390216512e3 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Sat, 23 Nov 2013 18:42:43 +0200 Subject: [PATCH] "yii\sphinx\ActiveQuery" updated to throw exception on conflict between "asArray" and "snippetByModel" options. --- extensions/sphinx/ActiveQuery.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/sphinx/ActiveQuery.php b/extensions/sphinx/ActiveQuery.php index c56ea2b..62a6ef0 100644 --- a/extensions/sphinx/ActiveQuery.php +++ b/extensions/sphinx/ActiveQuery.php @@ -7,6 +7,7 @@ namespace yii\sphinx; +use yii\base\InvalidCallException; use yii\db\ActiveQueryInterface; use yii\db\ActiveQueryTrait; @@ -186,10 +187,14 @@ class ActiveQuery extends Query implements ActiveQueryInterface /** * Fetches the source for the snippets using [[ActiveRecord::getSnippetSource()]] method. * @param ActiveRecord[] $models raw query result rows. + * @throws \yii\base\InvalidCallException if [[asArray]] enabled. * @return array snippet source strings */ protected function fetchSnippetSourceFromModels($models) { + if ($this->asArray) { + throw new InvalidCallException('"' . __METHOD__ . '" unable to determine snippet source from plain array. Either disable "asArray" option or use regular "snippetCallback"'); + } $result = []; foreach ($models as $model) { $result[] = $model->getSnippetSource();