ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ToolProxy.php
Go to the documentation of this file.
1<?php
2
4
7
18{
19
25 public $id = null;
26
32 private $consumer = null;
38 private $consumerId = null;
44 private $recordId = null;
50 private $dataConnector = null;
56 private $toolProxy = null;
57
64 public function __construct($dataConnector, $id = null)
65 {
66
67 $this->initialize();
68 $this->dataConnector = $dataConnector;
69 if (!empty($id)) {
70 $this->load($id);
71 } else {
72 $this->recordId = DataConnector::getRandomString(32);
73 }
74
75 }
76
80 public function initialize()
81 {
82
83 $this->id = null;
84 $this->recordId = null;
85 $this->toolProxy = null;
86 $this->created = null;
87 $this->updated = null;
88
89 }
90
96 public function initialise()
97 {
98
99 $this->initialize();
100
101 }
102
108 public function getRecordId()
109 {
110
111 return $this->recordId;
112
113 }
114
120 public function setRecordId($recordId)
121 {
122
123 $this->recordId = $recordId;
124
125 }
126
132 public function getConsumer()
133 {
134
135 if (is_null($this->consumer)) {
136 $this->consumer = ToolConsumer::fromRecordId($this->consumerId, $this->getDataConnector());
137 }
138
139 return $this->consumer;
140
141 }
142
148 public function setConsumerId($consumerId)
149 {
150
151 $this->consumer = null;
152 $this->consumerId = $consumerId;
153
154 }
155
161 public function getDataConnector()
162 {
163
164 return $this->dataConnector;
165
166 }
167
168
169###
170### PRIVATE METHOD
171###
172
180 private function load($id)
181 {
182
183 $this->initialize();
184 $this->id = $id;
185 $ok = $this->dataConnector->loadToolProxy($this);
186 if (!$ok) {
187 $this->enabled = $autoEnable;
188 }
189
190 return $ok;
191
192 }
193
194}
An exception for terminatinating execution or to throw for unit testing.
Class to provide a connection to a persistent store for LTI objects.
static getRandomString($length=8)
Generate a random string.
Class to represent an LTI Tool Proxy media type.
Definition: ToolProxy.php:18
static fromRecordId($id, $dataConnector)
Load the tool consumer from the database by its record ID.
$toolProxy
Tool Proxy document.
Definition: ToolProxy.php:56
initialise()
Initialise the tool proxy.
Definition: ToolProxy.php:96
initialize()
Initialise the tool proxy.
Definition: ToolProxy.php:80
$dataConnector
Data connector object.
Definition: ToolProxy.php:50
setConsumerId($consumerId)
Set tool consumer ID.
Definition: ToolProxy.php:148
$consumerId
Tool Consumer ID for this tool proxy.
Definition: ToolProxy.php:38
getDataConnector()
Get the data connector.
Definition: ToolProxy.php:161
__construct($dataConnector, $id=null)
Class constructor.
Definition: ToolProxy.php:64
load($id)
Load the tool proxy from the database.
Definition: ToolProxy.php:180
getRecordId()
Get the tool proxy record ID.
Definition: ToolProxy.php:108
setRecordId($recordId)
Sets the tool proxy record ID.
Definition: ToolProxy.php:120
$consumer
Definition: demo.php:30
if(!array_key_exists('StateId', $_REQUEST)) $id