
| Current Path : /var/www/html/ift/web/core/lib/Drupal/Core/StreamWrapper/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/ift/web/core/lib/Drupal/Core/StreamWrapper/PrivateStream.php |
<?php
namespace Drupal\Core\StreamWrapper;
use Drupal\Core\Site\Settings;
use Drupal\Core\Url;
/**
* Drupal private (private://) stream wrapper class.
*
* Provides support for storing privately accessible files with the Drupal file
* interface.
*/
class PrivateStream extends LocalStream {
/**
* {@inheritdoc}
*/
public static function getType() {
return StreamWrapperInterface::LOCAL_NORMAL;
}
/**
* {@inheritdoc}
*/
public function getName() {
return t('Private files');
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return t('Private local files served by Drupal.');
}
/**
* {@inheritdoc}
*/
public function getDirectoryPath() {
return static::basePath();
}
/**
* {@inheritdoc}
*/
public function getExternalUrl() {
$path = str_replace('\\', '/', $this->getTarget());
return Url::fromRoute('system.private_file_download', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE])->toString();
}
/**
* Returns the base path for private://.
*
* Note that this static method is used by \Drupal\system\Form\FileSystemForm
* so you should alter that form or substitute a different form if you change
* the class providing the stream_wrapper.private service.
*
* @return string
* The base path for private://.
*/
public static function basePath() {
return Settings::get('file_private_path');
}
}