LTI Integration Library 4.10.3
PHP class library for building LTI integrations
 
Loading...
Searching...
No Matches
FileItem.php
1<?php
2
3namespace ceLTIc\LTI\Content;
4
12class FileItem extends Item
13{
14
20 private $copyAdvice = null;
21
27 private $expiresAt = null;
28
35 function __construct($placementAdvices = null, $id = null)
36 {
37 parent::__construct(Item::TYPE_FILE, $placementAdvices, $id);
38 }
39
45 public function setCopyAdvice($copyAdvice)
46 {
47 $this->copyAdvice = $copyAdvice;
48 }
49
55 public function setExpiresAt($expiresAt)
56 {
57 $this->expiresAt = $expiresAt;
58 }
59
65 public function toJsonldObject()
66 {
67 $item = parent::toJsonldObject();
68 if (!is_null($this->copyAdvice)) {
69 $item->copyAdvice = $this->copyAdvice;
70 }
71 if (!empty($this->expiresAt)) {
72 $item->expiresAt = gmdate('Y-m-d\TH:i:s\Z', $this->expiresAt);
73 }
74
75 return $item;
76 }
77
83 public function toJsonObject()
84 {
85 $item = parent::toJsonObject();
86 if (!empty($this->expiresAt)) {
87 $item->expiresAt = gmdate('Y-m-d\TH:i:s\Z', $this->expiresAt);
88 }
89
90 return $item;
91 }
92
98 protected function fromJsonObject($item)
99 {
100 parent::fromJsonObject($item);
101 foreach (get_object_vars($item) as $name => $value) {
102 switch ($name) {
103 case 'copyAdvice':
104 case 'expiresAt':
105 $this->{$name} = $item->{$name};
106 break;
107 }
108 }
109 }
110
111}
Class to represent a file content-item object.
Definition FileItem.php:13
__construct($placementAdvices=null, $id=null)
Class constructor.
Definition FileItem.php:35
toJsonObject()
Wrap the content items to form a complete value for the https://purl.imsglobal.org/spec/lti-dl/claim/...
Definition FileItem.php:83
fromJsonObject($item)
Extract content-item details from its JSON representation.
Definition FileItem.php:98
setCopyAdvice($copyAdvice)
Set copy advice for the content-item.
Definition FileItem.php:45
setExpiresAt($expiresAt)
Set expiry date/time for the content-item.
Definition FileItem.php:55
toJsonldObject()
Wrap the content item to form an item complying with the application/vnd.ims.lti.v1....
Definition FileItem.php:65
Class to represent a content-item object.
const TYPE_FILE
Type for file content-item.