mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
FIX Replace Object reference with Injector and use ModuleLoader to resolve schema location
This commit is contained in:
parent
fc51d1a62e
commit
216613d746
@ -3,6 +3,9 @@
|
|||||||
namespace SilverStripe\FullTextSearch\Solr;
|
namespace SilverStripe\FullTextSearch\Solr;
|
||||||
|
|
||||||
use SilverStripe\Control\Director;
|
use SilverStripe\Control\Director;
|
||||||
|
use SilverStripe\Core\Injector\Injector;
|
||||||
|
use SilverStripe\Core\Manifest\Module;
|
||||||
|
use SilverStripe\Core\Manifest\ModuleLoader;
|
||||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||||
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
||||||
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
|
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
|
||||||
@ -79,18 +82,22 @@ class Solr
|
|||||||
// Build some by-version defaults
|
// Build some by-version defaults
|
||||||
$version = isset(self::$solr_options['version']) ? self::$solr_options['version'] : $defaults['version'];
|
$version = isset(self::$solr_options['version']) ? self::$solr_options['version'] : $defaults['version'];
|
||||||
|
|
||||||
|
/** @var Module $module */
|
||||||
|
$module = ModuleLoader::getModule('silverstripe/fulltextsearch');
|
||||||
|
$modulePath = $module->getPath();
|
||||||
|
|
||||||
if (version_compare($version, '4', '>=')) {
|
if (version_compare($version, '4', '>=')) {
|
||||||
$versionDefaults = array(
|
$versionDefaults = [
|
||||||
'service' => Solr4Service::class,
|
'service' => Solr4Service::class,
|
||||||
'extraspath' => Director::baseFolder().'/fulltextsearch/conf/solr/4/extras/',
|
'extraspath' => $modulePath . '/conf/solr/4/extras/',
|
||||||
'templatespath' => Director::baseFolder().'/fulltextsearch/conf/solr/4/templates/',
|
'templatespath' => $modulePath . '/conf/solr/4/templates/',
|
||||||
);
|
];
|
||||||
} else {
|
} else {
|
||||||
$versionDefaults = array(
|
$versionDefaults = [
|
||||||
'service' => Solr3Service::class,
|
'service' => Solr3Service::class,
|
||||||
'extraspath' => Director::baseFolder().'/fulltextsearch/conf/solr/3/extras/',
|
'extraspath' => $modulePath . '/conf/solr/3/extras/',
|
||||||
'templatespath' => Director::baseFolder().'/fulltextsearch/conf/solr/3/templates/',
|
'templatespath' => $modulePath . '/conf/solr/3/templates/',
|
||||||
);
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (self::$merged_solr_options = array_merge($defaults, $versionDefaults, self::$solr_options));
|
return (self::$merged_solr_options = array_merge($defaults, $versionDefaults, self::$solr_options));
|
||||||
@ -119,7 +126,7 @@ class Solr
|
|||||||
$options = self::solr_options();
|
$options = self::solr_options();
|
||||||
|
|
||||||
if (!self::$service_singleton) {
|
if (!self::$service_singleton) {
|
||||||
self::$service_singleton = Object::create(
|
self::$service_singleton = Injector::inst()->create(
|
||||||
$options['service'],
|
$options['service'],
|
||||||
$options['host'],
|
$options['host'],
|
||||||
$options['port'],
|
$options['port'],
|
||||||
|
@ -82,7 +82,8 @@ abstract class SolrIndex extends SearchIndex
|
|||||||
public function getTemplatesPath()
|
public function getTemplatesPath()
|
||||||
{
|
{
|
||||||
$globalOptions = Solr::solr_options();
|
$globalOptions = Solr::solr_options();
|
||||||
return $this->templatesPath ? $this->templatesPath : $globalOptions['templatespath'];
|
$path = $this->templatesPath ? $this->templatesPath : $globalOptions['templatespath'];
|
||||||
|
return rtrim($path, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||||
|
|
||||||
|
use Monolog\Handler\StreamHandler;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use SilverStripe\Core\Injector\Injector;
|
use SilverStripe\Core\Injector\Injector;
|
||||||
use SilverStripe\Dev\BuildTask;
|
use SilverStripe\Dev\BuildTask;
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
|
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -21,13 +22,13 @@ class Solr_BuildTask extends BuildTask
|
|||||||
protected $logger = null;
|
protected $logger = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current logger
|
* Get the monolog logger
|
||||||
*
|
*
|
||||||
* @return LoggerInterface
|
* @return LoggerInterface
|
||||||
*/
|
*/
|
||||||
public function getLogger()
|
public function getLogger()
|
||||||
{
|
{
|
||||||
return Injector::inst()->get(LoggerInterface::class);
|
return $this->logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user