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