ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ILIAS\WebDAV\Objects\IRSSStreamHandler Class Reference
+ Inheritance diagram for ILIAS\WebDAV\Objects\IRSSStreamHandler:
+ Collaboration diagram for ILIAS\WebDAV\Objects\IRSSStreamHandler:

Public Member Functions

 __construct (private ?ResourceIdentification $resource_identification)
 
 get ()
 
 put (string $title, mixed $data, bool $publish)
 
 publish ()
 
 get ()
 
 publish ()
 
 put (string $title, mixed $data, bool $publish)
 

Private Attributes

Manager $manager
 
Consumers $consumer
 
ilObjFileStakeholder $stakeholder
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 34 of file IRSSStreamHandler.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\WebDAV\Objects\IRSSStreamHandler::__construct ( private ?ResourceIdentification  $resource_identification)

Definition at line 42 of file IRSSStreamHandler.php.

44 {
45 global $DIC; // TODO remove Service Locator
46 $this->manager = $DIC->resourceStorage()->manage();
47 $this->consumer = $DIC->resourceStorage()->consume();
48 $this->stakeholder = new \ilObjFileStakeholder();
49 }
global $DIC
Definition: shib_login.php:26

References $DIC.

Member Function Documentation

◆ get()

ILIAS\WebDAV\Objects\IRSSStreamHandler::get ( )

Implements ILIAS\WebDAV\Objects\StreamHandler.

Definition at line 51 of file IRSSStreamHandler.php.

51 : ?FileStream
52 {
53 if ($this->resource_identification === null) {
54 return null;
55 }
56 try {
57 return $this->consumer->stream($this->resource_identification)->getStream();
58 } catch (\Throwable) {
59 return null;
60 }
61 }

◆ publish()

ILIAS\WebDAV\Objects\IRSSStreamHandler::publish ( )

Implements ILIAS\WebDAV\Objects\StreamHandler.

Definition at line 109 of file IRSSStreamHandler.php.

109 : void
110 {
111 if ($this->manager->getCurrentRevisionIncludingDraft(
112 $this->resource_identification
113 )->getStatus() === RevisionStatus::DRAFT
114 ) {
115 $this->manager->publish($this->resource_identification);
116 }
117 }

References ILIAS\ResourceStorage\Revision\DRAFT.

◆ put()

ILIAS\WebDAV\Objects\IRSSStreamHandler::put ( string  $title,
mixed  $data,
bool  $publish 
)

Implements ILIAS\WebDAV\Objects\StreamHandler.

Definition at line 63 of file IRSSStreamHandler.php.

63 : bool
64 {
65 if (is_resource($data)) {
66 $stream = Streams::ofResource($data);
67 } elseif (is_string($data) && $data !== '') {
68 $stream = Streams::ofString($data);
69 } else {
70 return false;
71 }
72
73 // Detect the empty `_Empty` placeholder revision created in
74 // TreeProxyRepository::createObject(). If the resource currently holds
75 // only that single DRAFT placeholder, remove it after the real
76 // revision has been published so the file does not appear with two
77 // versions (one empty, one with content).
78 $placeholder_revision_number = null;
79 $resource = $this->manager->getResource($this->resource_identification);
80 if (count($resource->getAllRevisionsIncludingDraft()) === 1) {
81 $only = $resource->getCurrentRevisionIncludingDraft();
82 if ($only->getStatus() === RevisionStatus::DRAFT) {
83 $placeholder_revision_number = $only->getVersionNumber();
84 }
85 }
86
87 $this->manager->appendNewRevisionFromStream(
88 $this->resource_identification,
89 $stream,
90 $this->stakeholder,
91 $title,
92 true
93 );
94
95 if ($publish) {
96 $this->manager->publish($this->resource_identification);
97 }
98
99 if ($placeholder_revision_number !== null && $publish) {
100 $this->manager->removeRevision(
101 $this->resource_identification,
102 $placeholder_revision_number
103 );
104 }
105
106 return true;
107 }
static ofString(string $string)
Creates a new stream with an initial value.
Definition: Streams.php:41
static ofResource($resource)
Wraps an already created resource with the stream abstraction.
Definition: Streams.php:64

References $data, ILIAS\ResourceStorage\Revision\DRAFT, ILIAS\Filesystem\Stream\Streams\ofResource(), and ILIAS\Filesystem\Stream\Streams\ofString().

+ Here is the call graph for this function:

Field Documentation

◆ $consumer

Consumers ILIAS\WebDAV\Objects\IRSSStreamHandler::$consumer
private

Definition at line 39 of file IRSSStreamHandler.php.

◆ $manager

Manager ILIAS\WebDAV\Objects\IRSSStreamHandler::$manager
private

Definition at line 38 of file IRSSStreamHandler.php.

◆ $stakeholder

ilObjFileStakeholder ILIAS\WebDAV\Objects\IRSSStreamHandler::$stakeholder
private

Definition at line 40 of file IRSSStreamHandler.php.


The documentation for this class was generated from the following file: