mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
ENHANCEMENT: add ability to use customised or project-sepcific filse for those Solr config extras, such as a stopwords.txt, which is very likely already exists if using sphinx previously for an upgrading project
This commit is contained in:
parent
fd8c721799
commit
9a446f54ae
@ -76,6 +76,7 @@ class Solr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Solr_Configure extends BuildTask {
|
class Solr_Configure extends BuildTask {
|
||||||
|
static $customised_conf_extra_path=null;
|
||||||
|
|
||||||
public function run($request) {
|
public function run($request) {
|
||||||
$service = Solr::service();
|
$service = Solr::service();
|
||||||
@ -90,7 +91,6 @@ class Solr_Configure extends BuildTask {
|
|||||||
case 'file':
|
case 'file':
|
||||||
$local = $index['path'];
|
$local = $index['path'];
|
||||||
$remote = isset($index['remotepath']) ? $index['remotepath'] : $local;
|
$remote = isset($index['remotepath']) ? $index['remotepath'] : $local;
|
||||||
|
|
||||||
foreach (Solr::get_indexes() as $index => $instance) {
|
foreach (Solr::get_indexes() as $index => $instance) {
|
||||||
$confdir = "$local/$index/conf";
|
$confdir = "$local/$index/conf";
|
||||||
if (!is_dir($confdir)) mkdir($confdir, 0770, true);
|
if (!is_dir($confdir)) mkdir($confdir, 0770, true);
|
||||||
@ -98,7 +98,19 @@ class Solr_Configure extends BuildTask {
|
|||||||
file_put_contents("$confdir/schema.xml", $instance->generateSchema());
|
file_put_contents("$confdir/schema.xml", $instance->generateSchema());
|
||||||
|
|
||||||
foreach (glob(Director::baseFolder().'/fulltextsearch/conf/extras/*') as $file) {
|
foreach (glob(Director::baseFolder().'/fulltextsearch/conf/extras/*') as $file) {
|
||||||
if (is_file($file)) copy($file, $confdir.'/'.basename($file));
|
if (is_file($file)){
|
||||||
|
if(self::$customised_conf_extra_path) {
|
||||||
|
$filename = basename($file);
|
||||||
|
$file_customised = Director::baseFolder().'/'.self::$customised_conf_extra_path.'/'.$filename;
|
||||||
|
if(is_file($file_customised)){
|
||||||
|
copy($file_customised, $confdir.'/'.$filename);
|
||||||
|
}else{
|
||||||
|
copy($file, $confdir.'/'.basename($file));
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
copy($file, $confdir.'/'.basename($file));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user