ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
LoggedAttachmentDelivery.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilLogger;
24
30{
31 public function __construct(
32 private readonly AddressedAttachmentDelivery $delivery,
33 private readonly ilLogger $logger,
34 private readonly int $acting_usr_id
35 ) {
36 }
37
38 public function forumObjId(): int
39 {
40 return $this->delivery->forumObjId();
41 }
42
43 public function containerId(): int
44 {
45 return $this->delivery->containerId();
46 }
47
48 public function deliverFile(string $revision_token): void
49 {
50 try {
51 $this->delivery->deliverFile($revision_token);
52 } catch (AttachmentAccessDenied $denial) {
53 $this->record($denial);
54
55 throw $denial;
56 }
57 }
58
59 public function deliverZipFile(): bool
60 {
61 try {
62 return $this->delivery->deliverZipFile();
63 } catch (AttachmentAccessDenied $denial) {
64 $this->record($denial);
65
66 throw $denial;
67 }
68 }
69
70 private function record(AttachmentAccessDenied $denial): void
71 {
72 $this->logger->warning(
73 'Denied forum attachment request: ' . $denial->reason()->logMessage(),
74 [
75 'reason' => $denial->reason()->value,
76 'forum_obj_id' => $this->delivery->forumObjId(),
77 'container_id' => $this->delivery->containerId(),
78 'usr_id' => $this->acting_usr_id
79 ]
80 );
81 }
82}
Records denied attachment requests, so repeated attempts to address a container through a foreign for...
__construct(private readonly AddressedAttachmentDelivery $delivery, private readonly ilLogger $logger, private readonly int $acting_usr_id)
Component logger with individual log levels by component id.
A delivery that exposes the identifiers it will resolve its resources from, so an access guard can ju...