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);
 }
Example #2
0
 public function updateFile(Project $project, File $file)
 {
     // Update log
     $entry = new Log();
     $entry->setProject($project);
     $entry->setOperation("update");
     $entry->setData(json_encode(array('name' => $file->getName(), 'program' => $file->getProgram())));
     $entry->setUser($this->user);
     $this->em->persist($entry);
     $this->em->flush();
 }