ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSimpleSAMLphpConfigTemplateHandler.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2/* Copyright (c) 1998-2017 ILIAS open source, Extended GPL, see docs/LICENSE */
3
5
10{
14 protected $fs;
15
20 public function __construct(Filesystem $fs)
21 {
22 $this->fs = $fs;
23 }
24
30 public function copy(string $sourcePath, string $destinationPath, array $placeholders = []) : void
31 {
32 if (!$this->fs->has($destinationPath)) {
33 $templateContents = file_get_contents($sourcePath);
34
35 foreach ($placeholders as $placeholder => $value) {
36 if (is_callable($value)) {
37 $value = $value();
38 }
39
40 $templateContents = str_replace('[[' . $placeholder . ']]', $value, $templateContents);
41 }
42
43 // Does not work because of .sec renaming of PHP files
44 //$this->fs->put($destinationPath, $templateContents);
45 file_put_contents(ilUtil::getDataDir() . '/' . $destinationPath, $templateContents);
46 }
47 }
48}
An exception for terminatinating execution or to throw for unit testing.
__construct(Filesystem $fs)
ilSimpleSAMLphpConfigTemplateHandler constructor.
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
static getDataDir()
get data directory (outside webspace)
Interface Filesystem.
Definition: Filesystem.php:27
Class FlySystemFileAccessTest.