/** * Saves a timesheet in a directory on the server * @param Timesheet $timesheet The timesheet to save locally */ private function saveLocally(Timesheet $timesheet) { $html = $timesheet->getHTML(); $this->dompdf->load_html($html); $this->dompdf->render(); $output = $this->dompdf->output(); // This will currently save to the server timesheets created by a single user on the same day // Only one copy is stored in the database so only the most recent copy will be accessed using // the get() and getAll() methods but there is a potential for unaccessable files to exist and // pile up on the local server storage directory. $dir = self::$SAVE_DIRECTORY . $timesheet->getFilename() . '.pdf'; file_put_contents($dir, $output); }