Browse Source

"yii\sphinx\ActiveQuery" updated to throw exception on conflict between "asArray" and "snippetByModel" options.

tags/2.0.0-beta
Klimov Paul 11 years ago
parent
commit
5a8afcf720
  1. 5
      extensions/sphinx/ActiveQuery.php

5
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();

Loading…
Cancel
Save