Explicit namespace definition on YAML files

This commit is contained in:
Marco Hermo 2017-04-23 06:21:06 +12:00
parent da0a217aa0
commit 8228c762c9
22 changed files with 81 additions and 49 deletions

View File

@ -1,4 +1,4 @@
Injector: SilverStripe\Core\Injector\Injector:
RequestProcessor: RequestProcessor:
properties: properties:
filters: filters:

View File

@ -1,3 +1,3 @@
DataObject: SilverStripe\ORM\DataObject\DataObject:
extensions: extensions:
- 'SearchUpdater_ObjectHandler' - 'SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater_ObjectHandler'

View File

@ -1,13 +1,13 @@
--- ---
Name: defaultprocessor Name: defaultprocessor
--- ---
Injector: SilverStripe\Core\Injector\Injector:
SearchUpdateProcessor: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor:
class: SearchUpdateImmediateProcessor class: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor
SolrReindexHandler: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler:
class: SolrReindexImmediateHandler class: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexImmediateHandler
SearchLogFactory: SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory:
class: 'MonologFactory' class: 'SilverStripe\FullTextSearch\Utils\Logging\MonologFactory'
--- ---
Name: messagequeueprocessor Name: messagequeueprocessor
Only: Only:
@ -15,11 +15,11 @@ Only:
Except: Except:
Environment: 'dev' Environment: 'dev'
--- ---
Injector: SilverStripe\Core\Injector\Injector:
SearchUpdateProcessor: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor:
class: SearchUpdateMessageQueueProcessor class: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateMessageQueueProcessor
SolrReindexHandler: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler:
class: SolrReindexMessageHandler class: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexMessageHandler
--- ---
Name: queuedjobprocessor Name: queuedjobprocessor
Only: Only:
@ -27,8 +27,8 @@ Only:
Except: Except:
Environment: 'dev' Environment: 'dev'
--- ---
Injector: SilverStripe\Core\Injector\Injector:
SearchUpdateProcessor: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor:
class: SearchUpdateQueuedJobProcessor class: SilverStripe\FullTextSearch\Search\Processors\SearchUpdateQueuedJobProcessor
SolrReindexHandler: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler:
class: SolrReindexQueuedHandler class: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexQueuedHandler

View File

@ -2,6 +2,7 @@
namespace SilverStripe\FullTextSearch\Search; namespace SilverStripe\FullTextSearch\Search;
use ReflectionClass;
use SilverStripe\Core\Config\Config; use SilverStripe\Core\Config\Config;
use SilverStripe\Core\ClassInfo; use SilverStripe\Core\ClassInfo;
/** /**
@ -41,7 +42,7 @@ class FullTextSearch
if (self::$all_indexes === null) { if (self::$all_indexes === null) {
// Get declared indexes, or otherwise default to all subclasses of SearchIndex // Get declared indexes, or otherwise default to all subclasses of SearchIndex
$classes = Config::inst()->get(__CLASS__, 'indexes') $classes = Config::inst()->get(__CLASS__, 'indexes')
?: ClassInfo::subclassesFor('SearchIndex'); ?: ClassInfo::subclassesFor('SilverStripe\FullTextSearch\Solr\SearchIndex');
$hidden = array(); $hidden = array();
$candidates = array(); $candidates = array();

View File

@ -2,6 +2,8 @@
namespace SilverStripe\FullTextSearch\Search\Indexes; namespace SilverStripe\FullTextSearch\Search\Indexes;
use Exception;
use InvalidArgumentException;
use SilverStripe\View\ViewableData; use SilverStripe\View\ViewableData;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectSchema; use SilverStripe\ORM\DataObjectSchema;
@ -303,7 +305,7 @@ abstract class SearchIndex extends ViewableData
$type = $match[1]; $type = $match[1];
} }
list($type, $args) = Object::parse_class_spec($type); list($type, $args) = Object::parse_class_spec($type);
if (is_subclass_of($type, 'StringField')) { if (is_subclass_of($type, 'SilverStripe\ORM\FieldType\DBString')) {
$this->addFulltextField($field); $this->addFulltextField($field);
} }
} }

View File

@ -2,7 +2,12 @@
namespace SilverStripe\FullTextSearch\Search\Updaters; namespace SilverStripe\FullTextSearch\Search\Updaters;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\ORM\DB; use SilverStripe\ORM\DB;
use SilverStripe\Core\ClassInfo;
/** /**
* 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 index
* items. * items.

View File

@ -3,6 +3,7 @@ namespace SilverStripe\FullTextSearch\Solr;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
use SilverStripe\Core\Object; use SilverStripe\Core\Object;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
class Solr class Solr
{ {
@ -136,7 +137,7 @@ class Solr
public static function get_indexes() public static function get_indexes()
{ {
return FullTextSearch::get_indexes('SolrIndex'); return FullTextSearch::get_indexes('SilverStripe\FullTextSearch\Solr\SolrIndex');
} }
/** /**

View File

@ -3,6 +3,7 @@
namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers; namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\FullTextSearch\Solr\Solr; use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Solr\SolrIndex; use SilverStripe\FullTextSearch\Solr\SolrIndex;

View File

@ -3,7 +3,10 @@
namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers; namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use SilverStripe\Control\Director;
use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Solr\SolrIndex; use SilverStripe\FullTextSearch\Solr\SolrIndex;
use SilverStripe\ORM\DB;
/** /**
* Invokes an immediate reindex * Invokes an immediate reindex

View File

@ -44,7 +44,7 @@ abstract class SolrReindexQueuedJobBase implements QueuedJob
*/ */
protected function getLoggerFactory() protected function getLoggerFactory()
{ {
return Injector::inst()->get('SearchLogFactory'); return Injector::inst()->get('SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory');
} }
/** /**
@ -103,7 +103,7 @@ abstract class SolrReindexQueuedJobBase implements QueuedJob
*/ */
protected function getHandler() protected function getHandler()
{ {
return Injector::inst()->get('SolrReindexHandler'); return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
} }
public function jobFinished() public function jobFinished()

View File

@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
class Solr3Service extends SolrService class Solr3Service extends SolrService
{ {
private static $core_class = 'Solr3Service_Core'; private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr3Service';
} }

View File

@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
class Solr4Service extends SolrService class Solr4Service extends SolrService
{ {
private static $core_class = 'Solr4Service_Core'; private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr4Service';
} }

View File

@ -44,7 +44,7 @@ class Solr4Service_Core extends SolrService_Core
$rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>"; $rawPost = "<add overwrite=\"{$overwriteVal}\"{$commitWithinString}>";
foreach ($documents as $document) { foreach ($documents as $document) {
if ($document instanceof Apache_Solr_Document) { if ($document instanceof \Apache_Solr_Document) {
$rawPost .= $this->_documentToXmlFragment($document); $rawPost .= $this->_documentToXmlFragment($document);
} }
} }

View File

@ -10,7 +10,7 @@ Solr::include_client_api();
*/ */
class SolrService extends SolrService_Core class SolrService extends SolrService_Core
{ {
private static $core_class = 'SolrService_Core'; private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\SolrService';
/** /**
* Handle encoding the GET parameters and making the HTTP call to execute a core command * Handle encoding the GET parameters and making the HTTP call to execute a core command

View File

@ -2,6 +2,10 @@
namespace SilverStripe\FullTextSearch\Solr\Stores; namespace SilverStripe\FullTextSearch\Solr\Stores;
use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Utils\WebDAV;
/** /**
* Class SolrConfigStore_WebDAV * Class SolrConfigStore_WebDAV
* *

View File

@ -1,6 +1,9 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Dev\BuildTask; use SilverStripe\Dev\BuildTask;
use Psr\Log\LoggerInterface;
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
/** /**
* Abstract class for build tasks * Abstract class for build tasks
*/ */
@ -22,7 +25,7 @@ class Solr_BuildTask extends BuildTask
*/ */
public function getLogger() public function getLogger()
{ {
return Injector::inst()->get('Logger'); return Injector::inst()->get('Psr\Log\LoggerInterface');
} }
/** /**
@ -40,7 +43,7 @@ class Solr_BuildTask extends BuildTask
*/ */
protected function getLoggerFactory() protected function getLoggerFactory()
{ {
// return Injector::inst()->get('SearchLogFactory'); return Injector::inst()->get('SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory');
} }
/** /**
@ -55,9 +58,8 @@ class Solr_BuildTask extends BuildTask
// Set new logger // Set new logger
$logger = $this $logger = $this
->getLoggerFactory(); ->getLoggerFactory()
//@todo: Cannot instantiate interface SearchLogFactory ->getOutputLogger($name, $verbose);
// ->getOutputLogger($name, $verbose);
$this->setLogger($logger); $this->setLogger($logger);
} }
} }

View File

@ -1,5 +1,11 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use Exception;
use SilverStripe\Core\ClassInfo;
use SilverStripe\FullTextSearch\Solr\Solr;
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_File;
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_WebDAV;
class Solr_Configure extends Solr_BuildTask class Solr_Configure extends Solr_BuildTask
{ {
protected $enabled = true; protected $enabled = true;
@ -72,7 +78,7 @@ class Solr_Configure extends Solr_BuildTask
return new SolrConfigStore_File($indexstore); return new SolrConfigStore_File($indexstore);
} elseif ($mode == 'webdav') { } elseif ($mode == 'webdav') {
return new SolrConfigStore_WebDAV($indexstore); return new SolrConfigStore_WebDAV($indexstore);
} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, 'SolrConfigStore')) { } elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, 'SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore')) {
return new $mode($indexstore); return new $mode($indexstore);
} else { } else {
user_error('Unknown Solr index mode '.$indexstore['mode'], E_USER_ERROR); user_error('Unknown Solr index mode '.$indexstore['mode'], E_USER_ERROR);

View File

@ -1,5 +1,12 @@
<?php <?php
namespace SilverStripe\FullTextSearch\Solr\Tasks; namespace SilverStripe\FullTextSearch\Solr\Tasks;
use ReflectionClass;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\ORM\DataList;
/** /**
* Task used for both initiating a new reindex, as well as for processing incremental batches * Task used for both initiating a new reindex, as well as for processing incremental batches
* within a reindex. * within a reindex.
@ -34,9 +41,7 @@ class Solr_Reindex extends Solr_BuildTask
*/ */
protected function getHandler() protected function getHandler()
{ {
//@todo: this needs to determine the best class from a Factory implementation return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
//@todo: it was 'SolrReindexHandler' but that doesn't work on 4.0
return Injector::inst()->get('SolrReindexImmediateHandler');
} }
/** /**
@ -65,7 +70,7 @@ class Solr_Reindex extends Solr_BuildTask
// this is for when index names do not match the class name (this can be done by overloading getIndexName() on // this is for when index names do not match the class name (this can be done by overloading getIndexName() on
// indexes // indexes
if ($index && !ClassInfo::exists($index)) { if ($index && !ClassInfo::exists($index)) {
foreach(ClassInfo::subclassesFor('SolrIndex') as $solrIndexClass) { foreach(ClassInfo::subclassesFor('SilverStripe\FullTextSearch\Solr\SolrIndex') as $solrIndexClass) {
$reflection = new ReflectionClass($solrIndexClass); $reflection = new ReflectionClass($solrIndexClass);
//skip over abstract classes //skip over abstract classes
if (!$reflection->isInstantiable()) { if (!$reflection->isInstantiable()) {

View File

@ -4,6 +4,8 @@ use Monolog\Formatter\FormatterInterface;
use Monolog\Formatter\LineFormatter; use Monolog\Formatter\LineFormatter;
use Monolog\Handler\HandlerInterface; use Monolog\Handler\HandlerInterface;
use Monolog\Logger; use Monolog\Logger;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Control\Director;
/** /**
* Provides logging based on monolog * Provides logging based on monolog

View File

@ -56,16 +56,16 @@ All possible parameters incl optional ones with example values:
Solr::configure_server(array( Solr::configure_server(array(
'host' => 'localhost', // default: localhost | The host or IP Solr is listening on 'host' => 'localhost', // default: localhost | The host or IP Solr is listening on
'port' => '8983', // default: 8983 | The port Solr is listening on 'port' => '8983', // default: 8983 | The port Solr is listening on
'path' => '/solr' // default: /solr | The suburl the solr service is available on 'path' => '/solr', // default: /solr | The suburl the solr service is available on
'version' => '4' // default: 4 | Solr server version - currently only 3 and 4 supported 'version' => '4', // default: 4 | Solr server version - currently only 3 and 4 supported
'service' => 'Solr4Service' // default: depends on version, Solr3Service for 3, Solr4Service for 4 | the class that provides actual communcation to the Solr server 'service' => 'Solr4Service', // default: depends on version, Solr3Service for 3, Solr4Service for 4 | the class that provides actual communcation to the Solr server
'extraspath' => BASE_PATH .'/fulltextsearch/conf/solr/4/extras/' // default: <basefolder>/fulltextsearch/conf/solr/{version}/extras/ | Absolute path to the folder containing templates which are used for generating the schema and field definitions. 'extraspath' => BASE_PATH .'/fulltextsearch/conf/solr/4/extras/', // default: <basefolder>/fulltextsearch/conf/solr/{version}/extras/ | Absolute path to the folder containing templates which are used for generating the schema and field definitions.
'templates' => BASE_PATH . '/fulltextsearch/conf/solr/4/templates/' // default: <basefolder>/fulltextsearch/conf/solr/{version}/templates/ | Absolute path to the configuration default files, e.g. solrconfig.xml 'templates' => BASE_PATH . '/fulltextsearch/conf/solr/4/templates/', // default: <basefolder>/fulltextsearch/conf/solr/{version}/templates/ | Absolute path to the configuration default files, e.g. solrconfig.xml
'indexstore' => array( 'indexstore' => array(
'mode' => 'file', // a classname which implements SolrConfigStore, or 'file' or 'webdav' 'mode' => 'file', // a classname which implements SolrConfigStore, or 'file' or 'webdav'
'path' => BASE_PATH . '/.solr' // The (locally accessible) path to write the index configurations to OR The suburl on the solr host that is set up to accept index configurations via webdav 'path' => BASE_PATH . '/.solr', // The (locally accessible) path to write the index configurations to OR The suburl on the solr host that is set up to accept index configurations via webdav
'remotepath' => '/opt/solr/config' // default (file mode only): same as 'path' above | The path that the Solr server will read the index configurations from 'remotepath' => '/opt/solr/config', // default (file mode only): same as 'path' above | The path that the Solr server will read the index configurations from
'auth' => 'solr:solr' // default: none | Webdav only - A username:password pair string to use to auth against the webdav server 'auth' => 'solr:solr', // default: none | Webdav only - A username:password pair string to use to auth against the webdav server
'port' => '80' // default: same as solr port | The port for WebDAV if different from the Solr port 'port' => '80' // default: same as solr port | The port for WebDAV if different from the Solr port
) )
)); ));

View File

@ -106,7 +106,7 @@ class SolrReindexQueuedTest extends SapphireTest
*/ */
protected function getHandler() protected function getHandler()
{ {
return Injector::inst()->get('SolrReindexHandler'); return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
} }
/** /**

View File

@ -102,7 +102,7 @@ class SolrReindexTest extends SapphireTest
*/ */
protected function getHandler() protected function getHandler()
{ {
return Injector::inst()->get('SolrReindexHandler'); return Injector::inst()->get('SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler');
} }
/** /**