ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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 $modification_time = @filemtime($uri);
39 // try to shorten uri
40 $base = BaseDirObjective::get();
41 if ($base !== null) {
42 $uri = str_replace($base, '', $uri);
43 }
44
46 'p' => $uri,
47 'n' => $file_name,
48 'mt' => $modification_time,
49 ]);
50 }
51
52 public static function fromArray(array $raw_payload): self
53 {
54 return new self(
55 $raw_payload['p'],
56 $raw_payload['n'],
57 $raw_payload['mt'] ?? false
58 );
59 }
60
61 public function getUri(): string
62 {
63 $uri = $this->uri;
64 // try to expand uri
65 $base = BaseDirObjective::get();
66 if ($base !== null) {
67 return $base . $uri;
68 }
69
70 return $uri;
71 }
72
73 public function getMimeType(): string
74 {
75 return $this->mime_type;
76 }
77
78 public function getFileName(): string
79 {
80 return $this->file_name;
81 }
82
83 public function getDisposition(): string
84 {
85 return $this->disposition;
86 }
87
88 public function getUserId(): int
89 {
90 return $this->user_id;
91 }
92}
__construct(private string $uri, private string $file_name)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc