See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 3 namespace IMSGlobal\LTI\ToolProvider; 4 5 use IMSGlobal\LTI\ToolProvider\DataConnector\DataConnector; 6 use IMSGlobal\LTI\ToolProvider\MediaType; 7 8 /** 9 * Class to represent an LTI Tool Proxy 10 * 11 * @author Stephen P Vickers <svickers@imsglobal.org> 12 * @copyright IMS Global Learning Consortium Inc 13 * @date 2016 14 * @version 3.0.2 15 * @license GNU Lesser General Public License, version 3 (<http://www.gnu.org/licenses/lgpl.html>) 16 */ 17 class ToolProxy 18 { 19 20 /** 21 * Local id of tool consumer. 22 * 23 * @var string $id 24 */ 25 public $id = null; 26 27 /** 28 * Tool Consumer for this tool proxy. 29 * 30 * @var ToolConsumer $consumer 31 */ 32 private $consumer = null; 33 /** 34 * Tool Consumer ID for this tool proxy. 35 * 36 * @var int $consumerId 37 */ 38 private $consumerId = null; 39 /** 40 * Consumer ID value. 41 * 42 * @var int $id 43 */ 44 private $recordId = null; 45 /** 46 * Data connector object. 47 * 48 * @var DataConnector $dataConnector 49 */ 50 private $dataConnector = null; 51 /** 52 * Tool Proxy document. 53 * 54 * @var MediaType\ToolProxy $toolProxy 55 */ 56 private $toolProxy = null; 57 58 /** 59 * Class constructor. 60 * 61 * @param DataConnector $dataConnector Data connector 62 * @param string $id Tool Proxy ID (optional, default is null) 63 */ 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 77 /** 78 * Initialise the tool proxy. 79 */ 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 91 /** 92 * Initialise the tool proxy. 93 * 94 * Pseudonym for initialize(). 95 */ 96 public function initialise() 97 { 98 99 $this->initialize(); 100 101 } 102 103 /** 104 * Get the tool proxy record ID. 105 * 106 * @return int Tool Proxy record ID value 107 */ 108 public function getRecordId() 109 { 110 111 return $this->recordId; 112 113 } 114 115 /** 116 * Sets the tool proxy record ID. 117 * 118 * @param int $recordId Tool Proxy record ID value 119 */ 120 public function setRecordId($recordId) 121 { 122 123 $this->recordId = $recordId; 124 125 } 126 127 /** 128 * Get tool consumer. 129 * 130 * @return ToolConsumer Tool consumer object for this context. 131 */ 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 143 /** 144 * Set tool consumer ID. 145 * 146 * @param int $consumerId Tool Consumer ID for this resource link. 147 */ 148 public function setConsumerId($consumerId) 149 { 150 151 $this->consumer = null; 152 $this->consumerId = $consumerId; 153 154 } 155 156 /** 157 * Get the data connector. 158 * 159 * @return DataConnector Data connector object 160 */ 161 public function getDataConnector() 162 { 163 164 return $this->dataConnector; 165 166 } 167 168 169 ### 170 ### PRIVATE METHOD 171 ### 172 173 /** 174 * Load the tool proxy from the database. 175 * 176 * @param string $id The tool proxy id value 177 * 178 * @return boolean True if the tool proxy was successfully loaded 179 */ 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body