ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
InformationARRepository.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
4 
8 
15 {
16 
20  public function blank()
21  {
22  return new FileInformation();
23  }
24 
25 
29  public function store(Information $information, Revision $revision) : void
30  {
31  $internal = $this->getInternalID($revision);
32  $r = ARInformation::find($internal);
33  if (!$r instanceof ARInformation) {
34  $r = new ARInformation();
35  $r->setInternal($internal);
36  $r->setIdentification($revision->getIdentification()->serialize());
37  $r->create();
38  }
39  $r->setTitle($information->getTitle());
40  $r->setMimeType($information->getMimeType());
41  $r->setSize($information->getSize());
42  $r->update();
43  }
44 
45 
49  public function get(Revision $revision) : Information
50  {
51  $internal = $this->getInternalID($revision);
52 
53  $r = ARInformation::find($internal);
54  $i = new FileInformation();
55  if ($r instanceof ARInformation) {
56  $i->setTitle($r->getTitle());
57  $i->setSize($r->getSize());
58  $i->setMimeType($r->getMimeType());
59  }
60 
61  return $i;
62  }
63 
64 
65  public function delete(Information $information, Revision $revision) : void
66  {
67  $internal = $this->getInternalID($revision);
68  $r = ARInformation::find($internal);
69  if ($r instanceof ARInformation) {
70  $r->delete();
71  }
72  }
73 
74 
80  protected function getInternalID(Revision $revision) : string
81  {
82  return $revision->getIdentification()->serialize() . '_' . $revision->getVersionNumber();
83  }
84 }
$i
Definition: metadata.php:24