Commit be2b76d4 by Paul Klimov

Method "callSnippetsInternal" for the Sphinx Query extracted

parent 1e585707
......@@ -201,4 +201,19 @@ class ActiveQuery extends Query implements ActiveQueryInterface
}
return $result;
}
/**
* @inheritdoc
*/
protected function callSnippets(array $source)
{
$from = $this->from;
if ($from === null) {
/** @var ActiveRecord $modelClass */
$modelClass = $this->modelClass;
$tableName = $modelClass::indexName();
$from = [$tableName];
}
return $this->callSnippetsInternal($source, $from[0]);
}
}
......@@ -693,13 +693,25 @@ class Query extends Component implements QueryInterface
*/
protected function callSnippets(array $source)
{
return $this->callSnippetsInternal($source, $this->from[0]);
}
/**
* Builds a snippets from provided source data by the given index.
* @param array $source the source data to extract a snippet from.
* @param string $from name of the source index.
* @return array snippets list.
* @throws InvalidCallException in case [[match]] is not specified.
*/
protected function callSnippetsInternal(array $source, $from)
{
$connection = $this->getConnection();
$match = $this->match;
if ($match === null) {
throw new InvalidCallException('Unable to call snippets: "' . $this->className() . '::match" should be specified.');
}
return $connection->createCommand()
->callSnippets($this->from[0], $source, $match, $this->snippetOptions)
->callSnippets($from, $source, $match, $this->snippetOptions)
->queryColumn();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment