ENHANCEMENT Use namespace imports rather than fully qualified class names in strings

This commit is contained in:
Raissa North 2017-12-04 11:56:18 +13:00
parent 7f564956a5
commit 0c3b4ff95b
12 changed files with 42 additions and 38 deletions

View File

@ -30,7 +30,8 @@ class FullTextSearch
* abstract indexes). Can optionally be filtered to only return indexes that are subclasses of some class * abstract indexes). Can optionally be filtered to only return indexes that are subclasses of some class
* *
* @static * @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 * @param bool $rebuild - If true, don't use cached values
*/ */
public static function get_indexes($class = null, $rebuild = false) 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 * 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 * 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. * From then on, fulltext search system will only see those indexes passed in this most recent call.

View File

@ -2,21 +2,20 @@
namespace SilverStripe\FullTextSearch\Search\Processors; namespace SilverStripe\FullTextSearch\Search\Processors;
use DateTime;
use DateInterval;
use SilverStripe\FullTextSearch\Search\FullTextSearch; use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\ORM\FieldType\DBDatetime; use SilverStripe\ORM\FieldType\DBDatetime;
use DateTime;
use DateInterval;
use stdClass; use stdClass;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
return;
}
use Symbiote\QueuedJobs\Services\QueuedJob; use Symbiote\QueuedJobs\Services\QueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJobService; use Symbiote\QueuedJobs\Services\QueuedJobService;
if (!interface_exists(QueuedJob::class)) {
return;
}
class SearchUpdateCommitJobProcessor implements QueuedJob class SearchUpdateCommitJobProcessor implements QueuedJob
{ {
/** /**

View File

@ -4,14 +4,13 @@ namespace SilverStripe\FullTextSearch\Search\Processors;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use stdClass; use stdClass;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
return;
}
use Symbiote\QueuedJobs\Services\QueuedJob; use Symbiote\QueuedJobs\Services\QueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJobService; use Symbiote\QueuedJobs\Services\QueuedJobService;
if (!interface_exists(QueuedJob::class)) {
return;
}
class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implements QueuedJob class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implements QueuedJob
{ {
/** /**

View File

@ -45,7 +45,7 @@ class SearchIntrospection
$classes = array_unique(array_merge($classes, array_values(ClassInfo::subclassesFor($class)))); $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) { if ($idx !== false) {
array_splice($classes, 0, $idx+1); array_splice($classes, 0, $idx+1);
} }

View File

@ -14,12 +14,12 @@ use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor
use ReflectionClass; use ReflectionClass;
/** /**
* This class is responsible for capturing changes to DataObjects and triggering index updates of the resulting dirty index * This class is responsible for capturing changes to DataObjects and triggering index updates of the resulting dirty
* items. * index items.
* *
* Attached automatically by _config calling SearchUpdater#bind_manipulation_capture. Overloads the current database connector's * Attached automatically by _config calling SearchUpdater#bind_manipulation_capture. Overloads the current database
* manipulate method - basically we need to capture a manipulation _after_ all the augmentManipulation code (for instance Version's) * connector's manipulate method - basically we need to capture a manipulation _after_ all the augmentManipulation code
* is run * (for instance Version's) is run
* *
* Pretty closely tied to the field structure of SearchIndex. * Pretty closely tied to the field structure of SearchIndex.
* *

View File

@ -11,15 +11,14 @@ use SilverStripe\Core\Injector\Injector;
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexQueuedJob; use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexQueuedJob;
use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexGroupQueuedJob; use SilverStripe\FullTextSearch\Solr\Reindex\Jobs\SolrReindexGroupQueuedJob;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateCommitJobProcessor; use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateCommitJobProcessor;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) {
return;
}
use Symbiote\QueuedJobs\Services\QueuedJob; use Symbiote\QueuedJobs\Services\QueuedJob;
use Symbiote\QueuedJobs\Services\QueuedJobService; use Symbiote\QueuedJobs\Services\QueuedJobService;
use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor; use Symbiote\QueuedJobs\DataObjects\QueuedJobDescriptor;
if (!interface_exists(QueuedJob::class)) {
return;
}
/** /**
* Represents a queued task to start the reindex job * Represents a queued task to start the reindex job
*/ */

View File

@ -2,7 +2,9 @@
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs; namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) { use Symbiote\QueuedJobs\Services\QueuedJob;
if (!interface_exists(QueuedJob::class)) {
return; return;
} }

View File

@ -2,7 +2,9 @@
namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs; namespace SilverStripe\FullTextSearch\Solr\Reindex\Jobs;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) { use Symbiote\QueuedJobs\Services\QueuedJob;
if (!interface_exists(QueuedJob::class)) {
return; return;
} }

View File

@ -8,13 +8,12 @@ use SilverStripe\Core\Injector\Injector;
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler; use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory; use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
use stdClass; use stdClass;
use Symbiote\QueuedJobs\Services\QueuedJob;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) { if (!interface_exists(QueuedJob::class)) {
return; return;
} }
use Symbiote\QueuedJobs\Services\QueuedJob;
/** /**
* Base class for jobs which perform re-index * Base class for jobs which perform re-index
*/ */

View File

@ -822,7 +822,8 @@ abstract class SolrIndex extends SearchIndex
// Extract string suggestion // Extract string suggestion
$suggestion = $this->getCollatedSuggestion($res->spellcheck->suggestions->collation); $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; $ret['Suggestion'] = $suggestion;
// A human friendly version of the suggestion, suitable for 'Did you mean $SuggestionNice?' display. // A human friendly version of the suggestion, suitable for 'Did you mean $SuggestionNice?' display.

View File

@ -5,9 +5,11 @@ namespace SilverStripe\FullTextSearch\Utils\Logging;
use Monolog\Formatter\FormatterInterface; use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
use Monolog\Handler\HandlerInterface; use Monolog\Handler\HandlerInterface;
use Monolog\Handler\StreamHandler;
use Monolog\Logger; use Monolog\Logger;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Injector\Injector;
use SilverStripe\FullTextSearch\Utils\Logging\QueuedJobLogHandler;
/** /**
* Provides logging based on monolog * Provides logging based on monolog
@ -53,7 +55,7 @@ class MonologFactory implements SearchLogFactory
// Unless cli, force output to php://output // Unless cli, force output to php://output
$stream = Director::is_cli() ? $stream : 'php://output'; $stream = Director::is_cli() ? $stream : 'php://output';
$handler = Injector::inst()->createWithArgs( $handler = Injector::inst()->createWithArgs(
'Monolog\Handler\StreamHandler', StreamHandler::class,
array($stream, $level, $bubble) array($stream, $level, $bubble)
); );
$handler->setFormatter($formatter); $handler->setFormatter($formatter);
@ -73,7 +75,7 @@ class MonologFactory implements SearchLogFactory
$format = "<p>$format</p>"; $format = "<p>$format</p>";
} }
return Injector::inst()->createWithArgs( return Injector::inst()->createWithArgs(
'Monolog\Formatter\LineFormatter', LineFormatter::class,
array($format) array($format)
); );
} }
@ -87,7 +89,7 @@ class MonologFactory implements SearchLogFactory
protected function getLoggerFor($name) protected function getLoggerFor($name)
{ {
return Injector::inst()->createWithArgs( return Injector::inst()->createWithArgs(
'Monolog\Logger', Logger::class,
array(strtolower($name)) array(strtolower($name))
); );
} }
@ -101,7 +103,7 @@ class MonologFactory implements SearchLogFactory
protected function getJobHandler($job) protected function getJobHandler($job)
{ {
return Injector::inst()->createWithArgs( return Injector::inst()->createWithArgs(
'SilverStripe\FullTextSearch\Utils\Logging\QueuedJobLogHandler', QueuedJobLogHandler::class,
array($job, Logger::INFO) array($job, Logger::INFO)
); );
} }

View File

@ -4,13 +4,12 @@ namespace SilverStripe\FullTextSearch\Utils\Logging;
use Monolog\Handler\AbstractProcessingHandler; use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger; use Monolog\Logger;
use Symbiote\QueuedJobs\Services\QueuedJob;
if (!interface_exists('Symbiote\QueuedJobs\Services\QueuedJob')) { if (!interface_exists(QueuedJob::class)) {
return; return;
} }
use Symbiote\QueuedJobs\Services\QueuedJob;
/** /**
* Handler for logging events into QueuedJob message data * Handler for logging events into QueuedJob message data
*/ */