ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
UploadHandler.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 use Closure;
30 
32 {
38  public function __construct(
39  private readonly Closure $link,
40  private readonly Closure $content,
41  private readonly Closure $txt
42  ) {
43  }
44 
45  public function getFileIdentifierParameterName(): string
46  {
47  return UploadHandlerInterface::DEFAULT_FILE_ID_PARAMETER;
48  }
49 
50  public function getUploadURL(): string
51  {
52  return $this->to('upload');
53  }
54 
55  public function getFileRemovalURL(): string
56  {
57  return $this->to('rm');
58  }
59 
60  public function getExistingFileInfoURL(): string
61  {
62  return $this->to('info');
63  }
64 
65  public function getInfoForExistingFiles(array $file_ids): array
66  {
67  return [];
68  }
69 
70  public function getInfoResult(string $identifier): ?FileInfoResult
71  {
72  return ($this->content)()->map(fn(DocumentContent $c) => new BasicFileInfoResult(
73  $identifier,
74  $identifier,
75  ($this->txt)('updated_document'),
76  strlen($c->value()),
77  $c->type()
78  ))->except(fn() => new Ok(null))->value();
79  }
80 
81  public function supportsChunkedUploads(): bool
82  {
83  return false;
84  }
85 
86  private function to(string $cmd): string
87  {
88  return ($this->link)($cmd);
89  }
90 }
__construct(private readonly Closure $link, private readonly Closure $content, private readonly Closure $txt)
$c
Definition: deliver.php:25
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:30
$txt
Definition: error.php:31
link(string $caption, string $href, bool $new_viewport=false)