mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
1728a62af5
Thanks to Marco Hermo and Brett Tasker for helping with this * Bump framework/cms to ^4.0@dev * WIP Silverstripe 4 compatibility fixes * more replacements and patches to migrate this module to 4.0 * Update composer.json * remove php <5.5 from travis.yml * WIP more SS4 compatibility fixes * WIP fix solr path to use DIR, avoid hardcoded module name * WIP respect current include path * WIP Namespacing and use on SearchIndex class * Namespacing for tests * WIP add namespaces to all classes * Second push of Test changes + namespacing * WIP split Solr files with multiple classes into single file / single class. Adjust namespaces * Fix PHP errors in test * break out search components with multiple classes into individual files and change namespaces * Update namespacing for Search indexes and variants in tests * Batch fixes for tests #2 * Update _config.php to use namespace * Use root namespace in referencing Apache_Solr_Document * Migrate task names so that the name is not fully qualified
53 lines
1.3 KiB
PHP
53 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\FullTextSearch\Solr\Stores;
|
|
|
|
|
|
/**
|
|
* Class SolrConfigStore_File
|
|
*
|
|
* A ConfigStore that uploads files to a Solr instance on a locally accessible filesystem
|
|
* by just using file copies
|
|
*/
|
|
class SolrConfigStore_File implements SolrConfigStore
|
|
{
|
|
public function __construct($config)
|
|
{
|
|
$this->local = $config['path'];
|
|
$this->remote = isset($config['remotepath']) ? $config['remotepath'] : $config['path'];
|
|
}
|
|
|
|
public function getTargetDir($index)
|
|
{
|
|
$targetDir = "{$this->local}/{$index}/conf";
|
|
|
|
if (!is_dir($targetDir)) {
|
|
$worked = @mkdir($targetDir, 0770, true);
|
|
|
|
if (!$worked) {
|
|
throw new RuntimeException(
|
|
sprintf('Failed creating target directory %s, please check permissions', $targetDir)
|
|
);
|
|
}
|
|
}
|
|
|
|
return $targetDir;
|
|
}
|
|
|
|
public function uploadFile($index, $file)
|
|
{
|
|
$targetDir = $this->getTargetDir($index);
|
|
copy($file, $targetDir.'/'.basename($file));
|
|
}
|
|
|
|
public function uploadString($index, $filename, $string)
|
|
{
|
|
$targetDir = $this->getTargetDir($index);
|
|
file_put_contents("$targetDir/$filename", $string);
|
|
}
|
|
|
|
public function instanceDir($index)
|
|
{
|
|
return $this->remote.'/'.$index;
|
|
}
|
|
} |