ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ShortFilePayload.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  'd' => filemtime($this->uri)
48  ]);
49  }
50 
51  public static function fromArray(array $raw_payload): self
52  {
53  return new self(
54  $raw_payload['p'],
55  $raw_payload['n'],
56  $raw_payload['d']
57  );
58  }
59 
60  public function getUri(): string
61  {
62  $uri = $this->uri;
63  // try to expand uri
64  $base = BaseDirObjective::get();
65  if ($base !== null) {
66  return $base . $uri;
67  }
68 
69  return $uri;
70  }
71 
72  public function getMimeType(): string
73  {
74  return $this->mime_type;
75  }
76 
77  public function getFileName(): string
78  {
79  return $this->file_name;
80  }
81 
82  public function getDisposition(): string
83  {
84  return $this->disposition;
85  }
86 
87  public function getUserId(): int
88  {
89  return $this->user_id;
90  }
91 }
__construct(Container $dic, ilPlugin $plugin)
__construct(private string $uri, private string $file_name)