1<?php 2 3namespace ceLTIc\LTI\MediaType; 4 5use ceLTIc\LTI\ToolProvider; 6use ceLTIc\LTI\Profile; 7 8/** 9 * Class to represent an LTI Resource Handler 10 * 11 * @author Stephen P Vickers <stephen@spvsoftwareproducts.com> 12 * @copyright SPV Software Products 13 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 14 */ 15class ResourceHandler 16{ 17 18 /** 19 * Class constructor. 20 * 21 * @param ToolProvider $toolProvider Tool Provider object 22 * @param Profile\ResourceHandler $resourceHandler Profile resource handler object 23 */ 24 function __construct($toolProvider, $resourceHandler) 25 { 26 $this->resource_type = new \stdClass; 27 $this->resource_type->code = $resourceHandler->item->id; 28 $this->resource_name = new \stdClass; 29 $this->resource_name->default_value = $resourceHandler->item->name; 30 $this->resource_name->key = "{$resourceHandler->item->id}.resource.name"; 31 $this->description = new \stdClass; 32 $this->description->default_value = $resourceHandler->item->description; 33 $this->description->key = "{$resourceHandler->item->id}.resource.description"; 34 $icon_info = new \stdClass; 35 $icon_info->default_location = new \stdClass; 36 $icon_info->default_location->path = $resourceHandler->icon; 37 $icon_info->key = "{$resourceHandler->item->id}.icon.path"; 38 $this->icon_info = array(); 39 $this->icon_info[] = $icon_info; 40 $this->message = array(); 41 foreach ($resourceHandler->requiredMessages as $message) { 42 $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered); 43 } 44 foreach ($resourceHandler->optionalMessages as $message) { 45 if (in_array($message->type, $toolProvider->consumer->profile->capability_offered)) { 46 $this->message[] = new Message($message, $toolProvider->consumer->profile->capability_offered); 47 } 48 } 49 } 50 51} 52