ILIAS  release_8 Revision v8.24
FileItem.php
Go to the documentation of this file.
1<?php
2
20
28class FileItem extends Item
29{
35 private ?bool $copyAdvice = null;
36
42 private ?int $expiresAt = null;
43
50 public function __construct($placementAdvices = null, ?string $id = null)
51 {
52 parent::__construct(Item::TYPE_FILE, $placementAdvices, $id);
53 }
54
59 public function setCopyAdvice(?bool $copyAdvice)
60 {
61 $this->copyAdvice = $copyAdvice;
62 }
63
68 public function setExpiresAt(?int $expiresAt)
69 {
70 $this->expiresAt = $expiresAt;
71 }
72
78 public function toJsonldObject(): object
79 {
80 $item = parent::toJsonldObject();
81 if (!is_null($this->copyAdvice)) {
82 $item->copyAdvice = $this->copyAdvice;
83 }
84 if (!empty($this->expiresAt)) {
85 $item->expiresAt = gmdate('Y-m-d\TH:i:s\Z', $this->expiresAt);
86 }
87
88 return $item;
89 }
90
96 public function toJsonObject(): object
97 {
98 $item = parent::toJsonObject();
99 if (!empty($this->expiresAt)) {
100 $item->expiresAt = gmdate('Y-m-d\TH:i:s\Z', $this->expiresAt);
101 }
102
103 return $item;
104 }
105
110 protected function fromJsonObject(object $item)
111 {
112 parent::fromJsonObject($item);
113 foreach (get_object_vars($item) as $name => $value) {
114 switch ($name) {
115 case 'copyAdvice':
116 case 'expiresAt':
117 $this->{$name} = $item->{$name};
118 break;
119 }
120 }
121 }
122}
Class to represent a file content-item object.
Definition: FileItem.php:29
__construct($placementAdvices=null, ?string $id=null)
Class constructor.
Definition: FileItem.php:50
setCopyAdvice(?bool $copyAdvice)
Set copy advice for the content-item.
Definition: FileItem.php:59
bool $copyAdvice
Copy advice for content-item.
Definition: FileItem.php:35
toJsonldObject()
Wrap the content item to form an item complying with the application/vnd.ims.lti.v1....
Definition: FileItem.php:78
fromJsonObject(object $item)
Extract content-item details from its JSON representation.
Definition: FileItem.php:110
int $expiresAt
Expiry date/time for content-item.
Definition: FileItem.php:42
setExpiresAt(?int $expiresAt)
Set expiry date/time for the content-item.
Definition: FileItem.php:68
toJsonObject()
Wrap the content items to form a complete value for the https://purl.imsglobal.org/spec/lti-dl/claim/...
Definition: FileItem.php:96
Class to represent a content-item object.
Definition: Item.php:32
const TYPE_FILE
Type for file content-item.
Definition: Item.php:51
string $id
ID of content-item.
Definition: Item.php:86
if($format !==null) $name
Definition: metadata.php:247
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: FileItem.php:19