Usage: $folder = new Folder('test'); if (!$folder->isEmpty()) { $folder->purge(); }
Inheritance: extends System
Example #1
0
 /**
  * Purge the data
  */
 public function purge()
 {
     // Purge the data
     Database::getInstance()->query("TRUNCATE TABLE tl_vimeo_cache");
     // Purge the images
     $folder = new \Folder(static::$imagesFolder);
     $folder->purge();
     // Log the action
     System::log('Purged the Vimeo cache', __METHOD__, TL_CRON);
 }
Example #2
0
 /**
  * Purge the temp folder
  */
 public function purgeTempFolder()
 {
     // Purge the folder
     $objFolder = new \Folder('system/tmp');
     $objFolder->purge();
     // Add a log entry
     $this->log('Purged the temp folder', __METHOD__, TL_CRON);
 }
Example #3
0
 /**
  * Protect a folder
  *
  * @throws InternalServerErrorException
  */
 public function protect()
 {
     if (!is_dir(TL_ROOT . '/' . $this->intId)) {
         throw new InternalServerErrorException('Resource "' . $this->intId . '" is not a directory.');
     }
     // Protect or unprotect the folder
     if (file_exists(TL_ROOT . '/' . $this->intId . '/.public')) {
         $objFolder = new \Folder($this->intId);
         $objFolder->protect();
         $this->import('Automator');
         $this->Automator->generateSymlinks();
         $this->log('Folder "' . $this->intId . '" has been protected', __METHOD__, TL_FILES);
     } else {
         $objFolder = new \Folder($this->intId);
         $objFolder->unprotect();
         $this->import('Automator');
         $this->Automator->generateSymlinks();
         $this->log('The protection from folder "' . $this->intId . '" has been removed', __METHOD__, TL_FILES);
     }
     $this->redirect($this->getReferer());
 }