Contao\Folder::unprotect PHP Method

unprotect() public method

Unprotect the folder by adding a .public file
public unprotect ( )
    public function unprotect()
    {
        if (!file_exists(TL_ROOT . '/' . $this->strFolder . '/.public')) {
            \File::putContent($this->strFolder . '/.public', '');
        }
    }

Usage Example

Esempio n. 1
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());
 }