Example #1
0
 public function updateProgram(File $program, $code, $statements)
 {
     // find corresponding project
     $project = $program->getProject();
     $projectPath = $this->pm->getProjectPath($project);
     $storageName = $this->getFilePath($program);
     $codePath = $projectPath . "/" . $storageName . "_code";
     $statementsPath = $projectPath . "/" . $storageName . "_statements";
     if ($code) {
         file_put_contents($codePath, $code, LOCK_EX);
     } else {
         touch($codePath);
     }
     if ($statements) {
         file_put_contents($statementsPath, $statements, LOCK_EX);
     } else {
         touch($satementsPath);
     }
     // update project
     $this->pm->updateFile($project, $program);
 }