Elgg  Version 4.x
ElggTempDiskFilestore.php
Go to the documentation of this file.
1 <?php
2 
4 
14 
18  protected $unique_sub_dir;
19 
25  public function __construct($directory_root = '') {
26 
27  if (!$directory_root) {
28  $directory_root = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . '/';
29  }
30 
31  $this->unique_sub_dir = uniqid() . '/';
32 
33  parent::__construct($directory_root);
34  }
35 
45  public function getFilenameOnFilestore(\ElggFile $file) {
46  $filename = $file->getFilename();
47  if (!$filename) {
48  return '';
49  }
50 
51  return Paths::sanitize($this->dir_root . $this->unique_sub_dir . $file->getFilename(), false);
52  }
53 
57  public function getParameters() {
58  $params = parent::getParameters();
59  $params['unique_sub_dir'] = $this->unique_sub_dir;
60 
61  return $params;
62  }
63 
67  public function setParameters(array $parameters) {
68 
69  if (isset($parameters['unique_sub_dir'])) {
70  $this->unique_sub_dir = $parameters['unique_sub_dir'];
71  }
72 
73  return parent::setParameters($parameters);
74  }
75 }
__construct($directory_root= '')
Construct a temp disk filestore using the given directory root.
$params
Saves global plugin settings.
Definition: save.php:13
setParameters(array $parameters)
{}
A filestore that uses disk as storage.
A filestore that uses disk as storage.
getFilename()
Return the filename.
Definition: ElggFile.php:96
getFilenameOnFilestore(\ElggFile $file)
Get the filename as saved on disk for an object.
$filename