5e1e56b9f50f73ef3135cac1389441160dbc1575
[yaffs-website] / web / core / lib / Drupal / Core / StreamWrapper / TemporaryStream.php
1 <?php
2
3 namespace Drupal\Core\StreamWrapper;
4
5 use Drupal\Core\Url;
6
7 /**
8  * Defines a Drupal temporary (temporary://) stream wrapper class.
9  *
10  * Provides support for storing temporarily accessible files with the Drupal
11  * file interface.
12  */
13 class TemporaryStream extends LocalStream {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static function getType() {
19     return StreamWrapperInterface::LOCAL_HIDDEN;
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function getName() {
26     return t('Temporary files');
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   public function getDescription() {
33     return t('Temporary local files for upload and previews.');
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function getDirectoryPath() {
40     return file_directory_temp();
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function getExternalUrl() {
47     $path = str_replace('\\', '/', $this->getTarget());
48     return Url::fromRoute('system.temporary', [], ['absolute' => TRUE, 'query' => ['file' => $path]])->toString();
49   }
50
51 }