Beispiel #1
0
 /**
  * Creates a file and puts the text in it; if the file exists, the content is overwritten.
  * @param string $path
  * @param string $text 
  */
 static function CreateWithText($path, $text)
 {
     $dir = Path::Directory($path);
     if (!Folder::Exists($dir)) {
         Folder::Create($dir);
     }
     file_put_contents($path, $text);
 }
 private function PrepareTargetFolder()
 {
     if (Folder::Exists($this->targetFolder)) {
         Folder::Delete($this->targetFolder);
     }
     Folder::Create($this->targetFolder, 0777);
     if (!Folder::Exists($this->targetFolder)) {
         throw new \Exception('TargetFolder not found and could not be created');
     }
     //TODO: !!Clear Folder!!
 }
Beispiel #3
0
 /**
  * Saves the template into the given file name
  */
 protected function OnSuccess()
 {
     $newTemplate = $this->Value('Name');
     $action = Action::Create();
     if ($this->template) {
         $action = Action::Update();
         $this->UpdateUsages($newTemplate);
         $oldFile = $this->CalcFile($this->template);
         if (File::Exists($oldFile)) {
             File::Delete($oldFile);
         }
     }
     $logger = new Logger(self::Guard()->GetUser());
     $logger->ReportTemplateAction($this->module->MyType(), $newTemplate, $action);
     if (!Folder::Exists($this->folder)) {
         Folder::Create($this->folder);
     }
     File::CreateWithText($this->CalcFile($newTemplate), $this->Value('Contents', false));
     Response::Redirect($this->BackLink());
 }