Method "callSnippetsInternal" for the Sphinx Query extracted

This commit is contained in:
Paul Klimov
2014-02-12 23:20:12 +02:00
parent 1e58570741
commit be2b76d40f
2 changed files with 28 additions and 1 deletions

View File

@ -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]);
}
}

View File

@ -692,6 +692,18 @@ class Query extends Component implements QueryInterface
* @return array snippets list.
*/
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;
@ -699,7 +711,7 @@ class Query extends Component implements QueryInterface
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();
}
}