Source of file SolrConfigStore_File.php
Size: 1,362 Bytes - Last Modified: 2021-12-23T10:31:32+00:00
/var/www/docs.ssmods.com/process/src/src/Solr/Stores/SolrConfigStore_File.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | <?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 = !empty($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; } } |