3 namespace Drupal\Core\StreamWrapper;
5 use Drupal\Core\Routing\UrlGeneratorTrait;
6 use Drupal\Core\Site\Settings;
9 * Drupal private (private://) stream wrapper class.
11 * Provides support for storing privately accessible files with the Drupal file
14 class PrivateStream extends LocalStream {
16 use UrlGeneratorTrait;
21 public static function getType() {
22 return StreamWrapperInterface::LOCAL_NORMAL;
28 public function getName() {
29 return t('Private files');
35 public function getDescription() {
36 return t('Private local files served by Drupal.');
42 public function getDirectoryPath() {
43 return static::basePath();
49 public function getExternalUrl() {
50 $path = str_replace('\\', '/', $this->getTarget());
51 return $this->url('system.private_file_download', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE]);
55 * Returns the base path for private://.
57 * Note that this static method is used by \Drupal\system\Form\FileSystemForm
58 * so you should alter that form or substitute a different form if you change
59 * the class providing the stream_wrapper.private service.
62 * The base path for private://.
64 public static function basePath() {
65 return Settings::get('file_private_path');