Mercurial > hg > isophonics-drupal-site
annotate core/lib/Drupal/Core/StreamWrapper/PrivateStream.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | af1871eacc83 |
children |
rev | line source |
---|---|
Chris@0 | 1 <?php |
Chris@0 | 2 |
Chris@0 | 3 namespace Drupal\Core\StreamWrapper; |
Chris@0 | 4 |
Chris@0 | 5 use Drupal\Core\Site\Settings; |
Chris@18 | 6 use Drupal\Core\Url; |
Chris@0 | 7 |
Chris@0 | 8 /** |
Chris@0 | 9 * Drupal private (private://) stream wrapper class. |
Chris@0 | 10 * |
Chris@0 | 11 * Provides support for storing privately accessible files with the Drupal file |
Chris@0 | 12 * interface. |
Chris@0 | 13 */ |
Chris@0 | 14 class PrivateStream extends LocalStream { |
Chris@0 | 15 |
Chris@0 | 16 /** |
Chris@0 | 17 * {@inheritdoc} |
Chris@0 | 18 */ |
Chris@0 | 19 public static function getType() { |
Chris@0 | 20 return StreamWrapperInterface::LOCAL_NORMAL; |
Chris@0 | 21 } |
Chris@0 | 22 |
Chris@0 | 23 /** |
Chris@0 | 24 * {@inheritdoc} |
Chris@0 | 25 */ |
Chris@0 | 26 public function getName() { |
Chris@0 | 27 return t('Private files'); |
Chris@0 | 28 } |
Chris@0 | 29 |
Chris@0 | 30 /** |
Chris@0 | 31 * {@inheritdoc} |
Chris@0 | 32 */ |
Chris@0 | 33 public function getDescription() { |
Chris@0 | 34 return t('Private local files served by Drupal.'); |
Chris@0 | 35 } |
Chris@0 | 36 |
Chris@0 | 37 /** |
Chris@0 | 38 * {@inheritdoc} |
Chris@0 | 39 */ |
Chris@0 | 40 public function getDirectoryPath() { |
Chris@0 | 41 return static::basePath(); |
Chris@0 | 42 } |
Chris@0 | 43 |
Chris@0 | 44 /** |
Chris@0 | 45 * {@inheritdoc} |
Chris@0 | 46 */ |
Chris@0 | 47 public function getExternalUrl() { |
Chris@0 | 48 $path = str_replace('\\', '/', $this->getTarget()); |
Chris@18 | 49 return Url::fromRoute('system.private_file_download', ['filepath' => $path], ['absolute' => TRUE, 'path_processing' => FALSE])->toString(); |
Chris@0 | 50 } |
Chris@0 | 51 |
Chris@0 | 52 /** |
Chris@0 | 53 * Returns the base path for private://. |
Chris@0 | 54 * |
Chris@0 | 55 * Note that this static method is used by \Drupal\system\Form\FileSystemForm |
Chris@0 | 56 * so you should alter that form or substitute a different form if you change |
Chris@0 | 57 * the class providing the stream_wrapper.private service. |
Chris@0 | 58 * |
Chris@0 | 59 * @return string |
Chris@0 | 60 * The base path for private://. |
Chris@0 | 61 */ |
Chris@0 | 62 public static function basePath() { |
Chris@0 | 63 return Settings::get('file_private_path'); |
Chris@0 | 64 } |
Chris@0 | 65 |
Chris@0 | 66 } |