ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ShortFilePayload.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
29{
30 protected string $mime_type = '';
31 protected string $disposition = '';
32 protected int $user_id = 0;
33
34 public function __construct(
35 private string $uri,
36 private string $file_name
37 ) {
38 // try to shorten uri
39 $base = BaseDirObjective::get();
40 if ($base !== null) {
41 $uri = str_replace($base, '', $uri);
42 }
43
45 'p' => $uri,
46 'n' => $file_name
47 ]);
48 }
49
50 public static function fromArray(array $raw_payload): self
51 {
52 return new self(
53 $raw_payload['p'],
54 $raw_payload['n']
55 );
56 }
57
58 public function getUri(): string
59 {
60 $uri = $this->uri;
61 // try to expand uri
62 $base = BaseDirObjective::get();
63 if ($base !== null) {
64 return $base . $uri;
65 }
66
67 return $uri;
68 }
69
70 public function getMimeType(): string
71 {
72 return $this->mime_type;
73 }
74
75 public function getFileName(): string
76 {
77 return $this->file_name;
78 }
79
80 public function getDisposition(): string
81 {
82 return $this->disposition;
83 }
84
85 public function getUserId(): int
86 {
87 return $this->user_id;
88 }
89}
__construct(private string $uri, private string $file_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc