| Total Complexity | 8 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class SolrConfigStore_File implements SolrConfigStore |
||
| 12 | { |
||
| 13 | public function __construct($config) |
||
| 17 | } |
||
| 18 | |||
| 19 | public function getTargetDir($index) |
||
| 20 | { |
||
| 21 | $targetDir = "{$this->local}/{$index}/conf"; |
||
| 22 | |||
| 23 | if (!is_dir($targetDir)) { |
||
| 24 | $worked = @mkdir($targetDir, 0770, true); |
||
| 25 | |||
| 26 | if (!$worked) { |
||
| 27 | throw new \RuntimeException( |
||
| 28 | sprintf('Failed creating target directory %s, please check permissions', $targetDir) |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | |||
| 33 | return $targetDir; |
||
| 34 | } |
||
| 35 | |||
| 36 | public function uploadFile($index, $file) |
||
| 37 | { |
||
| 38 | $targetDir = $this->getTargetDir($index); |
||
| 39 | copy($file, $targetDir . '/' . basename($file)); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function uploadString($index, $filename, $string) |
||
| 43 | { |
||
| 44 | $targetDir = $this->getTargetDir($index); |
||
| 45 | file_put_contents("$targetDir/$filename", $string); |
||
| 46 | } |
||
| 47 | |||
| 48 | public function instanceDir($index) |
||
| 51 | } |
||
| 52 | } |
||
| 53 |