Beispiel #1
0
 /**
  * Get content in template file
  * Using name of the host search template file.
  *
  * @param $hostName
  *
  * @return string
  */
 protected function getTemplateContent($hostName)
 {
     $files = $this->filesystem->files($this->templateDir);
     $content = '';
     array_walk($files, function ($file) use($hostName, &$content) {
         if (preg_match('/' . $hostName . '/', $file)) {
             $content = $this->filesystem->get($file);
         }
     });
     return $content;
 }
Beispiel #2
0
 public function addHost(HostManager $host)
 {
     $this->host = $host;
     $content = $this->getContent();
     $section = $this->getSection();
     $hostConfig = $this->getHostConfig();
     $new = true;
     if ($section) {
         $new = false;
     }
     $section = $this->buildSection($section, $hostConfig, $new);
     $newContent = $this->buildNewFileContent($content, $section, $new);
     $tempFile = $this->tempDir . DIRECTORY_SEPARATOR . 'hosts';
     $result = $this->filesystem->put($tempFile, $newContent);
     return $result;
 }