ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilSimpleSAMLphpConfigTemplateHandler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
28 {
29  public function __construct(private readonly Filesystem $fs)
30  {
31  }
32 
36  public function copy(string $sourcePath, string $destinationPath, array $placeholders = []): void
37  {
38  if (!$this->fs->has($destinationPath)) {
39  $templateContents = file_get_contents($sourcePath);
40 
41  foreach ($placeholders as $placeholder => $value) {
42  if (is_callable($value)) {
43  $value = $value();
44  }
45 
46  $templateContents = str_replace('[[' . $placeholder . ']]', $value, $templateContents);
47  }
48 
49  // Does not work because of .sec renaming of PHP files
50  //$this->fs->put($destinationPath, $templateContents);
51  file_put_contents(ilFileUtils::getDataDir() . '/' . $destinationPath, $templateContents);
52  }
53  }
54 }
copy(string $sourcePath, string $destinationPath, array $placeholders=[])
static getDataDir()
get data directory (outside webspace)