mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
Merge pull request #183 from creative-commoners/pulls/4.0/namespaces-over-classnames
ENHANCEMENT Use namespace imports over fully qualified class names
This commit is contained in:
commit
7d762012d9
@ -30,7 +30,8 @@ class FullTextSearch
|
||||
* abstract indexes). Can optionally be filtered to only return indexes that are subclasses of some class
|
||||
*
|
||||
* @static
|
||||
* @param String $class - Class name to filter indexes by, so that all returned indexes are subclasses of provided class
|
||||
* @param String $class - Class name to filter indexes by, so that all returned indexes are subclasses of provided
|
||||
* class
|
||||
* @param bool $rebuild - If true, don't use cached values
|
||||
*/
|
||||
public static function get_indexes($class = null, $rebuild = false)
|
||||
@ -99,7 +100,8 @@ class FullTextSearch
|
||||
/**
|
||||
* Sometimes, like when in tests, you want to restrain the actual indexes to a subset
|
||||
*
|
||||
* Call with one argument - an array of class names, index instances or classname => indexinstance pairs (can be mixed).
|
||||
* Call with one argument - an array of class names, index instances or classname => indexinstance pairs (can be
|
||||
* mixed).
|
||||
* Alternatively call with multiple arguments, each of which is a class name or index instance
|
||||
*
|
||||
* From then on, fulltext search system will only see those indexes passed in this most recent call.
|
||||
|
@ -2,21 +2,20 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use DateTime;
|
||||
use DateInterval;
|
||||
use stdClass;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
||||
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SearchUpdateCommitJobProcessor implements QueuedJob
|
||||
{
|
||||
/**
|
||||
|
@ -4,14 +4,13 @@ namespace SilverStripe\FullTextSearch\Search\Processors;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use stdClass;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
||||
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implements QueuedJob
|
||||
{
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class SearchIntrospection
|
||||
$classes = array_unique(array_merge($classes, array_values(ClassInfo::subclassesFor($class))));
|
||||
}
|
||||
|
||||
$idx = array_search('SilverStripe\ORM\DataObject', $classes);
|
||||
$idx = array_search(DataObject::class, $classes);
|
||||
if ($idx !== false) {
|
||||
array_splice($classes, 0, $idx+1);
|
||||
}
|
||||
|
@ -14,12 +14,12 @@ use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This class is responsible for capturing changes to DataObjects and triggering index updates of the resulting dirty index
|
||||
* items.
|
||||
* This class is responsible for capturing changes to DataObjects and triggering index updates of the resulting dirty
|
||||
* index items.
|
||||
*
|
||||
* Attached automatically by _config calling SearchUpdater#bind_manipulation_capture. Overloads the current database connector's
|
||||
* manipulate method - basically we need to capture a manipulation _after_ all the augmentManipulation code (for instance Version's)
|
||||
* is run
|
||||
* Attached automatically by _config calling SearchUpdater#bind_manipulation_capture. Overloads the current database
|
||||
* connector's manipulate method - basically we need to capture a manipulation _after_ all the augmentManipulation code
|
||||
* (for instance Version's) is run
|
||||
*
|
||||
* Pretty closely tied to the field structure of SearchIndex.
|
||||
*
|
||||
|
@ -11,15 +11,14 @@ use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexQueuedJob;
|
||||
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexGroupQueuedJob;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateCommitJobProcessor;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
return;
|
||||
}
|
||||
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
use Symbiote\QueuedJobs\Services\QueuedJobService;
|
||||
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
|
||||
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a queued task to start the reindex job
|
||||
*/
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,12 @@ use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
||||
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
|
||||
use stdClass;
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
/**
|
||||
* Base class for jobs which perform re-index
|
||||
*/
|
||||
|
@ -824,7 +824,8 @@ abstract class SolrIndex extends SearchIndex
|
||||
// Extract string suggestion
|
||||
$suggestion = $this->getCollatedSuggestion($res->spellcheck->suggestions->collation);
|
||||
|
||||
// The collation, including advanced query params (e.g. +), suitable for making another query programmatically.
|
||||
// The collation, including advanced query params (e.g. +), suitable for making another query
|
||||
// programmatically.
|
||||
$ret['Suggestion'] = $suggestion;
|
||||
|
||||
// A human friendly version of the suggestion, suitable for 'Did you mean $SuggestionNice?' display.
|
||||
|
@ -5,9 +5,11 @@ namespace SilverStripe\FullTextSearch\Utils\Logging;
|
||||
use Monolog\Formatter\FormatterInterface;
|
||||
use Monolog\Formatter\LineFormatter;
|
||||
use Monolog\Handler\HandlerInterface;
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\FullTextSearch\Utils\Logging\QueuedJobLogHandler;
|
||||
|
||||
/**
|
||||
* Provides logging based on monolog
|
||||
@ -53,7 +55,7 @@ class MonologFactory implements SearchLogFactory
|
||||
// Unless cli, force output to php://output
|
||||
$stream = Director::is_cli() ? $stream : 'php://output';
|
||||
$handler = Injector::inst()->createWithArgs(
|
||||
'Monolog\Handler\StreamHandler',
|
||||
StreamHandler::class,
|
||||
array($stream, $level, $bubble)
|
||||
);
|
||||
$handler->setFormatter($formatter);
|
||||
@ -73,7 +75,7 @@ class MonologFactory implements SearchLogFactory
|
||||
$format = "<p>$format</p>";
|
||||
}
|
||||
return Injector::inst()->createWithArgs(
|
||||
'Monolog\Formatter\LineFormatter',
|
||||
LineFormatter::class,
|
||||
array($format)
|
||||
);
|
||||
}
|
||||
@ -87,7 +89,7 @@ class MonologFactory implements SearchLogFactory
|
||||
protected function getLoggerFor($name)
|
||||
{
|
||||
return Injector::inst()->createWithArgs(
|
||||
'Monolog\Logger',
|
||||
Logger::class,
|
||||
array(strtolower($name))
|
||||
);
|
||||
}
|
||||
@ -101,7 +103,7 @@ class MonologFactory implements SearchLogFactory
|
||||
protected function getJobHandler($job)
|
||||
{
|
||||
return Injector::inst()->createWithArgs(
|
||||
'SilverStripe\FullTextSearch\Utils\Logging\QueuedJobLogHandler',
|
||||
QueuedJobLogHandler::class,
|
||||
array($job, Logger::INFO)
|
||||
);
|
||||
}
|
||||
|
@ -4,13 +4,12 @@ namespace SilverStripe\FullTextSearch\Utils\Logging;
|
||||
|
||||
use Monolog\Handler\AbstractProcessingHandler;
|
||||
use Monolog\Logger;
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
|
||||
if (!interface_exists(QueuedJob::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
use Symbiote\QueuedJobs\Services\QueuedJob;
|
||||
|
||||
/**
|
||||
* Handler for logging events into QueuedJob message data
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user