core-bundle/src/Resources/contao/drivers/DC_Folder.php
public function protect()
	{
		@trigger_error('Using DC_Folder::protect() has been deprecated and will no longer work in Contao 5.0. Use Contao\Folder::protect() and Contao\Folder::unprotect() instead.', E_USER_DEPRECATED);

		if (!is_dir($this->strRootDir . '/' . $this->intId))
		{
			throw new InternalServerErrorException('Resource "' . $this->intId . '" is not a directory.');
		}

		// Protect or unprotect the folder
		if (file_exists($this->strRootDir . '/' . $this->intId . '/.public'))
		{
			$objFolder = new Folder($this->intId);
			$objFolder->protect();

			$this->import(Automator::class, '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::class, 'Automator');
			$this->Automator->generateSymlinks();

			$this->log('The protection from folder "'.$this->intId.'" has been removed', __METHOD__, TL_FILES);
		}

		$this->redirect($this->getReferer());
	}
public function protect()
	{
		@trigger_error('Using DC_Folder::protect() has been deprecated and will no longer work in Contao 5.0. Use Contao\Folder::protect() and Contao\Folder::unprotect() instead.', E_USER_DEPRECATED);

		if (!is_dir($this->strRootDir . '/' . $this->intId))
		{
			throw new InternalServerErrorException('Resource "' . $this->intId . '" is not a directory.');
		}

		// Protect or unprotect the folder
		if (file_exists($this->strRootDir . '/' . $this->intId . '/.public'))
		{
			$objFolder = new Folder($this->intId);
			$objFolder->protect();

			$this->import(Automator::class, '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::class, 'Automator');
			$this->Automator->generateSymlinks();

			$this->log('The protection from folder "'.$this->intId.'" has been removed', __METHOD__, TL_FILES);
		}

		$this->redirect($this->getReferer());
	}
Protect a folder

@throws InternalServerErrorException

@deprecated Deprecated since Contao 4.7 to be removed in 5.0.
Use Contao\Folder::protect() and Contao\Folder::unprotect() instead.