コード例 #1
0
ファイル: Template.php プロジェクト: nocttuam/marvin
 /**
  * Build new content replacing tags in template content
  * Return final content
  *
  * @param HostManager $hostManager
  *
  * @return string
  */
 public function compile(HostManager $hostManager)
 {
     $this->hostManager = $hostManager;
     $this->templateDir = $this->configRepository->get('app.templates-dir');
     $content = $this->getTemplateContent($this->hostManager->get('host'));
     $content = $this->parseOptionalTags($content);
     $content = $this->parseRequiredTags($content);
     $content = $this->addID($content);
     $temporaryDir = $this->configRepository->get('app.temporary-dir');
     $dest = $temporaryDir . DIRECTORY_SEPARATOR . $this->hostManager->get('file-name');
     $result = $this->filesystem->put($dest, $content);
     return $result;
 }
コード例 #2
0
ファイル: EtcHostsManager.php プロジェクト: nocttuam/marvin
 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;
 }